Advertisement
Guest User

Untitled

a guest
Dec 8th, 2014
287
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 11.34 KB | None | 0 0
  1. diff --git a/apps/plugins/test_boost.c b/apps/plugins/test_boost.c
  2. index ec91206..97ffc02 100644
  3. diff --git a/firmware/drivers/audio/as3514.c b/firmware/drivers/audio/as3514.c
  4. index d8572df..f902377 100644
  5. --- a/firmware/drivers/audio/as3514.c
  6. +++ b/firmware/drivers/audio/as3514.c
  7. @@ -131,8 +131,8 @@ void audiohw_preinit(void)
  8.  
  9.  #ifdef HAVE_AS3543
  10.  
  11. -    as3514_write(AS3514_AUDIOSET1, AUDIOSET1_DAC_on | AUDIOSET1_DAC_GAIN_on);
  12. -    as3514_write(AS3514_AUDIOSET2, AUDIOSET2_AGC_off | AUDIOSET2_HPH_QUALITY_LOW_POWER);
  13. +    as3514_write(AS3514_AUDIOSET1, AUDIOSET1_DAC_on);
  14. +    as3514_write(AS3514_AUDIOSET2, AUDIOSET2_SUM_off | AUDIOSET2_AGC_off | AUDIOSET2_HPH_QUALITY_LOW_POWER);
  15.      /* common ground on, delay playback unmuting when inserting headphones */
  16.      as3514_write(AS3514_AUDIOSET3, AUDIOSET3_HPCM_on | AUDIOSET3_HP_LONGSTART);
  17.  
  18. @@ -144,8 +144,8 @@ void audiohw_preinit(void)
  19.      /* Select Line 2 for FM radio */
  20.      as3514_set(AS3514_LINE_IN1_R, LINE_IN_R_LINE_SELECT);
  21.  #endif
  22. -    /* Output SUM of microphone/line/DAC */
  23. -    as3514_write(AS3514_HPH_OUT_R, HPH_OUT_R_HEADPHONES | HPH_OUT_R_HP_OUT_SUM);
  24. +    /* Set LINEOUT to minimize pop-click noise in headphone on init stage  */
  25. +    as3514_write(AS3514_HPH_OUT_R, HPH_OUT_R_LINEOUT | HPH_OUT_R_HP_OUT_DAC);
  26.  
  27.  #else
  28.      /* as3514/as3515 */
  29. @@ -216,6 +216,11 @@ void audiohw_preinit(void)
  30.  
  31.      /* DAC_Mute_off */
  32.      as3514_set(AS3514_DAC_L, DAC_L_DAC_MUTE_off);
  33. +
  34. +#ifdef HAVE_AS3543
  35. +    /* DAC direct - gain, mixer and limitter bypassed */
  36. +    as3514_write(AS3514_HPH_OUT_R, HPH_OUT_R_HEADPHONES | HPH_OUT_R_HP_OUT_DAC);
  37. +#endif
  38.  }
  39.  
  40.  static void audiohw_mute(bool mute)
  41. @@ -291,7 +296,21 @@ void audiohw_set_volume(int vol_l, int vol_r)
  42.      } else {
  43.          mix_l = MIXER_MAX_VOLUME;
  44.          hph_l = vol_l - MIXER_MAX_VOLUME;
  45. -    }    
  46. +    }
  47. +
  48. +#ifdef HAVE_AS3543
  49. +    if (!(as3514_regs[AS3514_HPH_OUT_R] & 0x40)) {// if not radio or recording
  50. +        if (!hph_l || !hph_r) {
  51. +            as3514_write(AS3514_AUDIOSET1, AUDIOSET1_DAC_on | AUDIOSET1_DAC_GAIN_on);
  52. +            as3514_write(AS3514_AUDIOSET2, AUDIOSET2_AGC_off | AUDIOSET2_HPH_QUALITY_LOW_POWER);
  53. +            as3514_write_masked(AS3514_HPH_OUT_R, HPH_OUT_R_HP_OUT_SUM, HPH_OUT_R_HP_OUT_MASK);
  54. +        } else {
  55. +            as3514_write(AS3514_AUDIOSET1, AUDIOSET1_DAC_on);
  56. +            as3514_write(AS3514_AUDIOSET2, AUDIOSET2_SUM_off | AUDIOSET2_AGC_off | AUDIOSET2_HPH_QUALITY_LOW_POWER);
  57. +            as3514_write_masked(AS3514_HPH_OUT_R, HPH_OUT_R_HP_OUT_DAC, HPH_OUT_R_HP_OUT_MASK);
  58. +        }
  59. +    }
  60. +#endif
  61.  
  62.      as3514_write_masked(AS3514_DAC_R, mix_r, AS3514_VOL_MASK);
  63.      as3514_write_masked(AS3514_DAC_L, mix_l, AS3514_VOL_MASK);
  64. @@ -464,6 +483,9 @@ void audiohw_set_recvol(int left, int right, int type)
  65.  void audiohw_set_monitor(bool enable)
  66.  {
  67.      if (enable) {
  68. +#ifdef HAVE_AS3543
  69. +        as3514_write_masked(AS3514_HPH_OUT_R, HPH_OUT_R_HP_OUT_LINE, HPH_OUT_R_HP_OUT_MASK);
  70. +#endif
  71.          /* select either LIN1 or LIN2 */
  72.          as3514_write_masked(AS3514_AUDIOSET1, AUDIOSET1_LIN_on,
  73.                              AUDIOSET1_LIN1_on | AUDIOSET1_LIN2_on);
  74. @@ -471,6 +493,9 @@ void audiohw_set_monitor(bool enable)
  75.          as3514_set(AS3514_LINE_IN_L, LINE_IN1_L_LI1L_MUTE_off);
  76.      }
  77.      else {
  78. +#ifdef HAVE_AS3543
  79. +        as3514_write_masked(AS3514_HPH_OUT_R, HPH_OUT_R_HP_OUT_DAC, HPH_OUT_R_HP_OUT_MASK);
  80. +#endif
  81.          /* turn off both LIN1 and LIN2 (if present) */
  82.          as3514_clear(AS3514_LINE_IN1_R, LINE_IN1_R_LI1R_MUTE_off);
  83.          as3514_clear(AS3514_LINE_IN1_L, LINE_IN1_L_LI1L_MUTE_off);
  84. diff --git a/firmware/export/config/sansaclipplus.h b/firmware/export/config/sansaclipplus.h
  85. index 0bdf82d..0b4aa91 100644
  86. --- a/firmware/export/config/sansaclipplus.h
  87. +++ b/firmware/export/config/sansaclipplus.h
  88. @@ -176,7 +176,7 @@
  89.  #define CURRENT_MAX_CHG   150
  90.  
  91.  /* Define this to the CPU frequency */
  92. -#define CPU_FREQ      240000000
  93. +#define CPU_FREQ      38400000
  94.  
  95.  /* Type of LCD */
  96.  #define CONFIG_LCD LCD_SSD1303
  97. @@ -195,7 +195,7 @@
  98.  #define CONFIG_LED LED_VIRTUAL
  99.  
  100.  /* Define this if you have adjustable CPU frequency */
  101. -//#define HAVE_ADJUSTABLE_CPU_FREQ
  102. +#define HAVE_ADJUSTABLE_CPU_FREQ
  103.  
  104.  #define BOOTFILE_EXT    "sansa"
  105.  #define BOOTFILE        "rockbox." BOOTFILE_EXT
  106. diff --git a/firmware/export/config/sansaclipzip.h b/firmware/export/config/sansaclipzip.h
  107. index eaf51d9..d3aff83 100644
  108. --- a/firmware/export/config/sansaclipzip.h
  109. +++ b/firmware/export/config/sansaclipzip.h
  110. @@ -175,7 +175,7 @@
  111.  #define CURRENT_MAX_CHG   150
  112.  
  113.  /* Define this to the CPU frequency */
  114. -#define CPU_FREQ      240000000
  115. +#define CPU_FREQ      38400000
  116.  
  117.  /* Type of LCD */
  118.  #define CONFIG_LCD LCD_CLIPZIP
  119. @@ -194,7 +194,7 @@
  120.  #define CONFIG_LED LED_VIRTUAL
  121.  
  122.  /* Define this if you have adjustable CPU frequency */
  123. -//#define HAVE_ADJUSTABLE_CPU_FREQ
  124. +#define HAVE_ADJUSTABLE_CPU_FREQ
  125.  
  126.  #define BOOTFILE_EXT    "sansa"
  127.  #define BOOTFILE        "rockbox." BOOTFILE_EXT
  128. diff --git a/firmware/rolo.c b/firmware/rolo.c
  129. index 923199f..8976a3e 100644
  130. --- a/firmware/rolo.c
  131. +++ b/firmware/rolo.c
  132. @@ -267,6 +267,10 @@ int rolo_load(const char* filename)
  133.      lcd_remote_update();
  134.  #endif
  135.      adc_close();
  136. +#if CONFIG_CPU == AS3525v2
  137. +    /* Set CVDD1 power supply to default*/
  138. +    ascodec_write_pmu(0x17, 1, 0);
  139. +#endif
  140.  
  141.  #if CONFIG_CPU != IMX31L /* We're not finished yet */
  142.  #ifdef CPU_ARM
  143. diff --git a/firmware/target/arm/as3525/clock-target.h b/firmware/target/arm/as3525/clock-target.h
  144. index 97d6edb..7087313 100644
  145. --- a/firmware/target/arm/as3525/clock-target.h
  146. +++ b/firmware/target/arm/as3525/clock-target.h
  147. @@ -70,11 +70,8 @@
  148.   * - bit 12  = unknown (always set to 1)
  149.   * Fpll = Fin * F / (R * OD), where Fin = 12 MHz
  150.   */
  151. -#define AS3525_PLLA_FREQ        240000000
  152. -#define AS3525_PLLA_SETTING     0x113B
  153. -
  154. -#define AS3525_PLLB_FREQ        192000000   /* allows 44.1kHz with 0.04% error*/
  155. -#define AS3525_PLLB_SETTING     0x155F
  156. +#define AS3525_PLLA_FREQ        192000000   /* allows 44.1kHz with 0.04% error*/
  157. +#define AS3525_PLLA_SETTING     0x155F
  158.  
  159.  #define AS3525_FCLK_PREDIV      0
  160.  #define AS3525_FCLK_FREQ        AS3525_PLLA_FREQ
  161. @@ -91,7 +88,7 @@
  162.   * 34285715 HZ works ok but 40MHz works even better*/
  163.  #define AS3525_DRAM_FREQ        40000000    /* Initial DRAM frequency  */
  164.  #else
  165. -#define AS3525_DRAM_FREQ        24000000    /* Initial DRAM frequency  */
  166. +#define AS3525_DRAM_FREQ        96000000    /* Initial DRAM frequency  */
  167.  #endif /* SANSA_FUZEV2 */
  168.  
  169.  #else
  170. @@ -131,8 +128,8 @@
  171.  
  172.  /* Tell the software what frequencies we're running */
  173.  #define CPUFREQ_MAX              AS3525_FCLK_FREQ
  174. -#define CPUFREQ_DEFAULT          AS3525_PCLK_FREQ
  175. -#define CPUFREQ_NORMAL           AS3525_PCLK_FREQ
  176. +#define CPUFREQ_DEFAULT          38400000
  177. +#define CPUFREQ_NORMAL           CPUFREQ_DEFAULT
  178.  
  179.  /* FCLK */
  180.  #define AS3525_FCLK_SEL          AS3525_CLK_PLLA
  181. @@ -145,21 +142,8 @@
  182.  #endif /* CONFIG_CPU == AS3525v2 */
  183.  
  184.  /* MCLK */
  185. -#if CONFIG_CPU == AS3525v2
  186. -/* on AMSv2 we can enable PLLB for MCLK to increase PCM sample rate accuracy
  187. -   with no significant impact on battery life */
  188. -#define AS3525_MCLK_SEL          AS3525_CLK_PLLB
  189. -#else
  190.  #define AS3525_MCLK_SEL          AS3525_CLK_PLLA
  191. -#endif /* CONFIG_CPU == AS3525v2 */
  192. -
  193. -#if (AS3525_MCLK_SEL==AS3525_CLK_PLLA)
  194.  #define AS3525_MCLK_FREQ         AS3525_PLLA_FREQ
  195. -#elif (AS3525_MCLK_SEL==AS3525_CLK_PLLB)
  196. -#define AS3525_MCLK_FREQ         AS3525_PLLB_FREQ
  197. -#else
  198. -#error Choose either PLLA or PLLB for MCLK!
  199. -#endif
  200.  
  201.  /* PCLK */
  202.  
  203. diff --git a/firmware/target/arm/as3525/system-as3525.c b/firmware/target/arm/as3525/system-as3525.c
  204. index f128ef6..04692be 100644
  205. --- a/firmware/target/arm/as3525/system-as3525.c
  206. +++ b/firmware/target/arm/as3525/system-as3525.c
  207. @@ -306,8 +306,6 @@ void system_init(void)
  208.  
  209.      CGU_PERI |= CGU_ROM_ENABLE; /* needed for rebooting */
  210.  
  211. -    set_cpu_frequency(CPUFREQ_DEFAULT);
  212. -
  213.  #if 0 /* the GPIO clock is already enabled by the dualboot function */
  214.      CGU_PERI |= CGU_GPIO_CLOCK_ENABLE;
  215.  #endif
  216. @@ -336,8 +334,8 @@ void system_init(void)
  217.      /* AVDD17:    set AVDD17 power supply to 2.5V */
  218.      ascodec_write_pmu(0x18, 7, 0x31);
  219.  #ifdef SANSA_CLIPZIP
  220. -    /* CVDD2:     set CVDD2 power supply to 2.8V */
  221. -    ascodec_write_pmu(0x17, 2, 0xF4);
  222. +    /* CVDD2:     set CVDD2 power supply to 2.575V */
  223. +    ascodec_write_pmu(0x17, 2, 0x80 | 111);
  224.  #endif
  225.  #else /* HAVE_AS3543 */
  226.      ascodec_write(AS3514_CVDD_DCDC3, AS314_CP_DCDC3_SETTING);
  227. @@ -460,23 +458,25 @@ void set_cpu_frequency(long frequency)
  228.      }
  229.  }
  230.  #else   /* as3525v2  */
  231. -/* FIXME : disabled for now, seems to cause buggy memory accesses
  232. - * Disabling MMU or putting the function in uncached memory seems to help? */
  233. +static bool frequency_lock = false;
  234. +
  235.  void set_cpu_frequency(long frequency)
  236.  {
  237. -    int oldstatus = disable_irq_save();
  238. +    if(frequency_lock)
  239. +        return;
  240.  
  241. -    /* We only have 2 settings */
  242. -    cpu_frequency = (frequency == CPUFREQ_MAX) ? frequency : CPUFREQ_NORMAL;
  243. +    frequency_lock = true;
  244.  
  245.      if(frequency == CPUFREQ_MAX)
  246.      {
  247. -        /* Change PCLK while FCLK is low, so it doesn't go too high */
  248. -        CGU_PERI = (CGU_PERI & ~(0xF << 2)) | (AS3525_PCLK_DIV0 << 2);
  249. +        /* Set CVDD1 power supply */
  250. +        ascodec_write_pmu(0x17, 1, 0x80 | 47);
  251.  
  252.          CGU_PROC = ((AS3525_FCLK_POSTDIV << 4) |
  253.                      (AS3525_FCLK_PREDIV  << 2) |
  254.                      AS3525_FCLK_SEL);
  255. +
  256. +        cpu_frequency = CPUFREQ_MAX;
  257.      }
  258.      else
  259.      {
  260. @@ -484,11 +484,14 @@ void set_cpu_frequency(long frequency)
  261.                      (AS3525_FCLK_PREDIV  << 2) |
  262.                      AS3525_FCLK_SEL);
  263.  
  264. -        /* Change PCLK after FCLK is low, so it doesn't go too high */
  265. -        CGU_PERI = (CGU_PERI & ~(0xF << 2)) | (AS3525_PCLK_DIV0_UNBOOSTED << 2);
  266. +        cpu_frequency = CPUFREQ_NORMAL;
  267. +
  268. +        /* Set CVDD1 power supply */
  269. +        ascodec_write_pmu(0x17, 1, 0x80 | 19);
  270. +
  271.      }
  272.  
  273. -    restore_irq(oldstatus);
  274. +    frequency_lock = false;
  275.  }
  276.  #endif
  277.  
  278. diff --git a/firmware/target/arm/as3525/usb-as3525.c b/firmware/target/arm/as3525/usb-as3525.c
  279. index 99ae66d..094a2a9 100644
  280. --- a/firmware/target/arm/as3525/usb-as3525.c
  281. +++ b/firmware/target/arm/as3525/usb-as3525.c
  282. @@ -33,10 +33,21 @@ static int usb_status = USB_EXTRACTED;
  283.  void usb_enable(bool on)
  284.  {
  285.  #if defined(HAVE_USBSTACK) && defined(USE_ROCKBOX_USB)
  286. -    if (on)
  287. +    if (on) {
  288. +
  289. +          cpu_boost(1);
  290. +//        set_cpu_frequency(CPUFREQ_MAX);
  291. +//        cpu_frequency_lock(true);
  292. +//#endif
  293.          usb_core_init();
  294. -    else
  295. +    } else {
  296.          usb_core_exit();
  297. +//#if CONFIG_CPU == AS3525v2
  298. +        sleep(HZ);
  299. +        cpu_boost(0);
  300. +      //  cpu_frequency_lock(false);
  301. +//#endif
  302. +    }
  303.  #else
  304.      (void)on;
  305.  #endif
  306. diff --git a/firmware/target/arm/as3525/usb-drv-as3525.c b/firmware/target/arm/as3525/usb-drv-as3525.c
  307. index 01fae5f..2b3d690 100644
  308. --- a/firmware/target/arm/as3525/usb-drv-as3525.c
  309. +++ b/firmware/target/arm/as3525/usb-drv-as3525.c
  310. @@ -238,11 +238,11 @@ void usb_drv_init(void)
  311.          initialized = true;
  312.      }
  313.  
  314. -    usb_enable_pll();
  315. -
  316.      /* we have external power, so boost cpu */
  317.      cpu_boost(1);
  318.  
  319. +    usb_enable_pll();
  320. +
  321.      /* length regulator: normal operation */
  322.      ascodec_write(AS3514_CVDD_DCDC3, ascodec_read(AS3514_CVDD_DCDC3) | 1<<2);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement