SMDK6410: Hook up regulator supplies for WM8580
Subsystems (3)
PATCH 1/4 SMDK6410: Hook up regulator supplies for WM8580
DVDD is supplied by supplies derived from the PMIC, AVDD and PVDD are supplied from the main wall supply on the base board which runs at 5V. No option is currently supported for running without a PMIC card, the assumption is that the regulator API will be built out when no soft PMIC card is in use.
To ease merge issues since this uses the newly added dev_name supply configuration from the regulator API (currently in -next only) the fixed voltage regulator is ifdefed out when the regulator API is not enabled.
--- arch/arm/mach-s3c6410/mach-smdk6410.c | 52 +++++++++++++++++++++++++++++++++ 1 files changed, 52 insertions(+), 0 deletions(-)
arch/arm/mach-s3c6410/mach-smdk6410.c +52 -0
@@ -25,6 +25,7 @@#include <linux/gpio.h> #include <linux/delay.h> #include <linux/smsc911x.h> +#include <linux/regulator/fixed.h> #ifdef CONFIG_SMDK6410_WM1190_EV1 #include <linux/mfd/wm8350/core.h>
@@ -184,6 +185,43 @@ static struct platform_device smdk6410_smsc911x = { }, }; +#ifdef CONFIG_REGULATOR +static struct regulator_consumer_supply smdk6410_b_pwr_5v_consumers[] = { + { +/* WM8580 */ + .supply ="PVDD" , + .dev_name ="0-001b" , + }, + { +/* WM8580 */ + .supply ="AVDD" , + .dev_name ="0-001b" , + }, +}; + +static struct regulator_init_data smdk6410_b_pwr_5v_data = { + .constraints = { + .always_on =1 , + }, + .num_consumer_supplies =ARRAY_SIZE (smdk6410_b_pwr_5v_consumers), + .consumer_supplies = smdk6410_b_pwr_5v_consumers, +}; + +static struct fixed_voltage_config smdk6410_b_pwr_5v_pdata = { + .supply_name ="B_PWR_5V" , + .microvolts =5000000 , + .init_data = &smdk6410_b_pwr_5v_data, +}; + +static struct platform_device smdk6410_b_pwr_5v = { + .name ="reg-fixed-voltage" , + .id =-1 , + .dev = { + .platform_data = &smdk6410_b_pwr_5v_pdata, + }, +}; +#endif +static struct map_desc smdk6410_iodesc[] = {};static struct platform_device *smdk6410_devices[]__initdata = {
@@ -198,6 +236,10 @@ static struct platform_device *smdk6410_devices[] __initdata = { &s3c_device_fb, &s3c_device_usb, &s3c_device_usb_hsotg, + +#ifdef CONFIG_REGULATOR + &smdk6410_b_pwr_5v, +#endif &smdk6410_lcd_powerdev, &smdk6410_smsc911x,
@@ -232,6 +274,14 @@ static struct regulator_init_data wm8350_dcdc3_data = { };/* USB, EXT, PCM, ADC/DAC, USB, MMC */ +static struct regulator_consumer_supply wm8350_dcdc4_consumers[] = { + { +/* WM8580 */ + .supply ="DVDD" , + .dev_name ="0-001b" , + }, +}; +static struct regulator_init_data wm8350_dcdc4_data = { .constraints = { .name ="PVDD_HI/PVDD_EXT/PVDD_SYS/PVCCM2MTV" ,
@@ -239,6 +289,8 @@ static struct regulator_init_data wm8350_dcdc4_data = { .max_uV = 3000000, .always_on = 1, }, + .num_consumer_supplies = ARRAY_SIZE(wm8350_dcdc4_consumers), + .consumer_supplies = wm8350_dcdc4_consumers, };/* ARM core */
Signature · 1 line
1.6.5
PATCH 2/4 S3C64XX: Provide logging when CPU frequencies are eliminated due to clocks
This provides symmetry with the voltage based checks done for the regulator.
--- arch/arm/plat-s3c64xx/cpufreq.c | 5 ++++- 1 files changed, 4 insertions(+), 1 deletions(-)
arch/arm/plat-s3c64xx/cpufreq.c +4 -1
@@ -217,8 +217,11 @@ static int __init s3c64xx_cpufreq_driver_init(struct cpufreq_policy *policy)/* Check for frequencies we can generate */ r =clk_round_rate (armclk, freq->frequency *1000 ); r /=1000 ; -if (r != freq->frequency) +if (r != freq->frequency) { +pr_debug ("cpufreq: %dkHz unsupported by clock\n" , + freq->frequency); freq->frequency =CPUFREQ_ENTRY_INVALID ; + }/* If we have no regulator then assume startup * frequency is the maximum we can support. */
Signature · 1 line
1.6.5
PATCH 3/4 S3C64XX: Set rate of crystal mux
In reply to Mark BrownThe current code assumes that the external clock mux will be set to the crystal. Set this up explicitly within the clock API.
--- arch/arm/plat-s3c64xx/s3c6400-clock.c | 3 +++ 1 files changed, 3 insertions(+), 0 deletions(-)
arch/arm/plat-s3c64xx/s3c6400-clock.c +3 -0
@@ -677,6 +677,9 @@ void __init_or_cpufreq s3c6400_setup_clocks(void)printk (KERN_DEBUG "%s: xtal is %ld\n" , __func__, xtal); +/* For now assume the mux always selects the crystal */ + clk_ext_xtal_mux.parent = xtal_clk; + epll =s3c6400_get_epll (xtal); mpll =s3c6400_get_pll (xtal,__raw_readl (S3C_MPLL_CON )); apll =s3c6400_get_pll (xtal,__raw_readl (S3C_APLL_CON ));
Signature · 1 line
1.6.5
PATCH 4/4 S3C64XX: Provide control of APLL
In reply to Mark BrownSet up runtime control of APLL in the clock API. Since both APLL and MPLL use the same IP a generic PLL6552 clock is provided but at present only APLL is hooked up. Since the documentation recommends using only one of a specific list of configurations we do not attempt to calculate arbatrary PLL setups but instead choose from that list.
Note that reconfiguration of APLL may not be safe when SYNCMUX is set to clock HCLKx2 from the APLL mux since it will also change the state of that tree without notice.
--- arch/arm/plat-s3c64xx/s3c6400-clock.c | 83 +++++++++++++++++++++++++++++++-- 1 files changed, 78 insertions(+), 5 deletions(-)
arch/arm/plat-s3c64xx/s3c6400-clock.c +78 -5
@@ -63,14 +63,86 @@ struct clksrc_clk {void __iomem *reg_divider; }; -static struct clk clk_fout_apll = { - .name ="fout_apll" , - .id =-1 , +#define PLL6552_CON (mdiv, pdiv, sdiv) (0x8000000 | (mdiv << 16) | \ + (pdiv << 8) | sdiv) +#define PLL6552_MASK PLL6552_CON(0x1f, 0x3ff, 7) + +/* While PLL output can be calculated as MDIV * input / (PDIV * +* 2^SDIV) the datasheet recommends using one of the configurations +* listed below. +*/ +static const struct { +int input; +int output; +u32 reg; +} pll6552_cfg[] = { + {12000000 ,0 ,0 }, + {12000000 ,100000000 ,PLL6552_CON (400 ,3 ,4 ) }, + {12000000 ,200000000 ,PLL6552_CON (400 ,3 ,3 ) }, + {12000000 ,266000000 ,PLL6552_CON (266 ,3 ,2 ) }, + {12000000 ,400000000 ,PLL6552_CON (400 ,3 ,2 ) }, + {12000000 ,533000000 ,PLL6552_CON (266 ,3 ,1 ) }, + {12000000 ,667000000 ,PLL6552_CON (333 ,3 ,1 ) }, + {27000000 ,0 ,0 }, + {27000000 ,100000000 ,PLL6552_CON (474 ,8 ,4 ) }, + {27000000 ,200000000 ,PLL6552_CON (474 ,8 ,3 ) }, + {27000000 ,266000000 ,PLL6552_CON (276 ,7 ,2 ) }, + {27000000 ,400000000 ,PLL6552_CON (474 ,8 ,2 ) }, + {27000000 ,533000000 ,PLL6552_CON (276 ,7 ,1 ) }, + {27000000 ,667000000 ,PLL6552_CON (346 ,7 ,1 ) }, +}; + +struct pll6552_clk { +struct clk clk; +void __iomem *pll_con; +}; + +static unsigned long pll6552_get_rate (struct clk *clk) +{ +unsigned long parent =clk_get_rate (clk->parent); +struct pll6552_clk *pll6552 = + container_of(clk, struct pll6552_clk, clk); + +return s3c6400_get_pll (parent,__raw_readl (pll6552->pll_con)); +} + +static int pll6552_set_rate (struct clk *clk,unsigned long rate) +{ +unsigned long parent =clk_get_rate (clk->parent); +struct pll6552_clk *pll6552 = + container_of(clk, struct pll6552_clk, clk); +int i; +u32 val; + +for (i =0 ; i <ARRAY_SIZE (pll6552_cfg); i++) +if (pll6552_cfg[i].input == parent && + pll6552_cfg[i].output == rate) +break ; +if (i ==ARRAY_SIZE (pll6552_cfg)) +return -EINVAL ; + + val =__raw_readl (pll6552->pll_con); + val &= ~PLL6552_MASK ; + val |= pll6552_cfg[i].reg; + +__raw_writel (val, pll6552->pll_con); + +return 0 ; +} + +static struct pll6552_clk clk_fout_apll = { + .clk = { + .name ="fout_apll" , + .id =-1 , + .get_rate = pll6552_get_rate, + .set_rate = pll6552_set_rate, + }, + .pll_con =S3C_APLL_CON , };static struct clk *clk_src_apll_list[] = { [0 ] = &clk_fin_apll, - [1 ] = &clk_fout_apll, + [1 ] = &clk_fout_apll.clk, };static struct clk_sources clk_src_apll = {
@@ -698,7 +770,6 @@ void __init_or_cpufreq s3c6400_setup_clocks(void) clk_fout_mpll.rate = mpll; clk_fout_epll.rate = epll; - clk_fout_apll.rate = apll; clk_h2.rate = hclk2; clk_h.rate = hclk;
@@ -729,6 +800,7 @@ static struct clk *clks[] __initdata = { &clk_audio1.clk, &clk_irda.clk, &clk_camif.clk, + &clk_fout_apll.clk, &clk_arm, };
@@ -761,6 +833,7 @@ void __init s3c6400_register_clocks(unsigned armclk_divlimit) } } + clk_fout_apll.clk.parent = &clk_fin_apll; clk_mpll.parent = &clk_mout_mpll.clk; clk_epll.parent = &clk_mout_epll.clk; }
Signature · 1 line
1.6.5