1 #include <linux/regulator/machine.h>
2 #include <linux/mfd/wm831x/pdata.h>
3 #include <linux/mfd/wm831x/core.h>
4 #include <linux/mfd/wm831x/gpio.h>
5 #include <linux/mfd/wm831x/pmu.h>
9 #define cru_readl(offset) readl_relaxed(RK30_CRU_BASE + offset)
10 #define cru_writel(v, offset) do { writel_relaxed(v, RK30_CRU_BASE + offset); dsb(); } while (0)
12 #define grf_readl(offset) readl_relaxed(RK30_GRF_BASE + offset)
13 #define grf_writel(v, offset) do { writel_relaxed(v, RK30_GRF_BASE + offset); dsb(); } while (0)
15 #define CRU_CLKGATE5_CON_ADDR 0x00e4
16 #define GRF_GPIO6L_DIR_ADDR 0x0030
17 #define GRF_GPIO6L_DO_ADDR 0x0068
18 #define GRF_GPIO6L_EN_ADDR 0x00a0
19 #define CRU_CLKGATE5_GRFCLK_ON 0x00100000
20 #define CRU_CLKGATE5_GRFCLK_OFF 0x00100010
21 #define GPIO6_PB1_DIR_OUT 0x02000200
22 #define GPIO6_PB1_DO_LOW 0x02000000
23 #define GPIO6_PB1_DO_HIGH 0x02000200
24 #define GPIO6_PB1_EN_MASK 0x02000200
25 #define GPIO6_PB1_UNEN_MASK 0x02000000
28 #if defined(CONFIG_GPIO_WM831X)
29 static struct rk29_gpio_expander_info wm831x_gpio_settinginfo[] = {
31 .gpio_num = WM831X_P01, // tp3
33 .pin_value = GPIO_LOW,
36 .gpio_num = WM831X_P02, //tp4
40 .gpio_num = WM831X_P03, //tp2
42 .pin_value = GPIO_HIGH,
45 .gpio_num = WM831X_P04, //tp1
49 .gpio_num = WM831X_P05, //tp1
53 .gpio_num = WM831X_P06, //tp1
55 .pin_value = GPIO_HIGH,
58 .gpio_num = WM831X_P07, //tp1
62 .gpio_num = WM831X_P08, //tp1
64 .pin_value = GPIO_HIGH,
67 .gpio_num = WM831X_P09, //tp1
69 .pin_value = GPIO_HIGH,
72 .gpio_num = WM831X_P10, //tp1
76 .gpio_num = WM831X_P11, //tp1
78 .pin_value = GPIO_HIGH,
81 .gpio_num = WM831X_P12,
83 .pin_value = GPIO_HIGH,
88 #if defined(CONFIG_MFD_WM831X)
90 #define UNLOCK_SECURITY_KEY ~(0x1<<5)
91 #define LOCK_SECURITY_KEY 0x00
92 #define PMU_POWER_SLEEP RK30_PIN6_PB1
93 static struct wm831x *Wm831x;
95 static int wm831x_pre_init(struct wm831x *parm)
99 // printk("%s\n", __func__);
100 gpio_request(PMU_POWER_SLEEP, "NULL");
101 gpio_direction_output(PMU_POWER_SLEEP, GPIO_LOW);
103 #ifdef CONFIG_WM8326_VBAT_LOW_DETECTION
104 #ifdef CONFIG_BATTERY_RK30_VOL3V8
105 wm831x_set_bits(parm,WM831X_SYSVDD_CONTROL ,0xc077,0xc035); //pvdd power on dect vbat voltage
106 printk("+++The vbat is too low+++\n");
110 ret = wm831x_reg_read(parm, WM831X_POWER_STATE) & 0xffff;
111 wm831x_reg_write(parm, WM831X_POWER_STATE, (ret & 0xfff8) | 0x04);
113 wm831x_set_bits(parm, WM831X_RTC_CONTROL, WM831X_RTC_ALAM_ENA_MASK, 0x0400);//enable rtc alam
115 wm831x_reg_write(parm, WM831X_SECURITY_KEY, 0x9716); // unlock security key
116 wm831x_set_bits(parm, WM831X_RESET_CONTROL, 0x1003, 0x1001);
117 ret = wm831x_reg_read(parm, WM831X_RESET_CONTROL) & 0xffff & UNLOCK_SECURITY_KEY; // enternal reset active in sleep
118 // printk("%s:WM831X_RESET_CONTROL=0x%x\n", __func__, ret);
119 wm831x_reg_write(parm, WM831X_RESET_CONTROL, ret);
121 wm831x_set_bits(parm,WM831X_DC1_ON_CONFIG ,0x0300,0x0000); //set dcdc mode is FCCM
122 wm831x_set_bits(parm,WM831X_DC2_ON_CONFIG ,0x0300,0x0000);
123 wm831x_set_bits(parm,WM831X_DC3_ON_CONFIG ,0x0300,0x0000);
124 wm831x_set_bits(parm,0x4066,0x0300,0x0000);
126 #ifndef CONFIG_MACH_RK3066_SDK
127 wm831x_set_bits(parm,WM831X_LDO10_CONTROL ,0x0040,0x0040);// set ldo10 in switch mode
129 wm831x_set_bits(parm,WM831X_STATUS_LED_1 ,0xc300,0xc100);// set led1 on(in manual mode)
130 wm831x_set_bits(parm,WM831X_STATUS_LED_2 ,0xc300,0xc000);//set led2 off(in manual mode)
132 wm831x_set_bits(parm,WM831X_LDO5_SLEEP_CONTROL ,0xe000,0x2000);// set ldo5 is disable in sleep mode
133 wm831x_set_bits(parm,WM831X_LDO1_SLEEP_CONTROL ,0xe000,0x2000);// set ldo1 is disable in sleep mode
135 wm831x_reg_write(parm, WM831X_SECURITY_KEY, LOCK_SECURITY_KEY); // lock security key
139 static int wm831x_mask_interrupt(struct wm831x *Wm831x)
141 /**************************clear interrupt********************/
142 wm831x_reg_write(Wm831x,WM831X_INTERRUPT_STATUS_1,0xffff);
143 wm831x_reg_write(Wm831x,WM831X_INTERRUPT_STATUS_2,0xffff);
144 wm831x_reg_write(Wm831x,WM831X_INTERRUPT_STATUS_3,0xffff);
145 wm831x_reg_write(Wm831x,WM831X_INTERRUPT_STATUS_4,0xffff);
146 wm831x_reg_write(Wm831x,WM831X_INTERRUPT_STATUS_5,0xffff);
148 wm831x_reg_write(Wm831x,WM831X_SYSTEM_INTERRUPTS_MASK,0xbedc); //mask interrupt which not used
150 /*****************************************************************/
153 #ifdef CONFIG_WM8326_VBAT_LOW_DETECTION
154 static int wm831x_low_power_detection(struct wm831x *wm831x)
156 #ifdef CONFIG_BATTERY_RK30_VOL3V8
157 wm831x_reg_write(wm831x,WM831X_SYSTEM_INTERRUPTS_MASK,0xbe5c);
158 wm831x_set_bits(wm831x,WM831X_INTERRUPT_STATUS_1_MASK,0x8000,0x0000);
159 wm831x_set_bits(wm831x,WM831X_SYSVDD_CONTROL ,0xc077,0x0035); //set pvdd low voltage is 3.1v hi voltage is 3.3v
161 wm831x_reg_write(wm831x,WM831X_AUXADC_CONTROL,0x803f); //open adc
162 wm831x_reg_write(wm831x,WM831X_AUXADC_CONTROL,0xd03f);
163 wm831x_reg_write(wm831x,WM831X_AUXADC_SOURCE,0x0001);
165 wm831x_reg_write(wm831x,WM831X_COMPARATOR_CONTROL,0x0001);
166 wm831x_reg_write(wm831x,WM831X_COMPARATOR_1,0x2844); //set the low power is 3.1v
168 wm831x_reg_write(wm831x,WM831X_INTERRUPT_STATUS_1_MASK,0x99ee);
169 wm831x_set_bits(wm831x,WM831X_SYSTEM_INTERRUPTS_MASK,0x0100,0x0000);
170 if (wm831x_reg_read(wm831x,WM831X_AUXADC_DATA)< 0x1844){
171 printk("The vbat is too low.\n");
172 wm831x_device_shutdown(wm831x);
180 int wm831x_post_init(struct wm831x *Wm831x)
182 struct regulator *dcdc;
183 struct regulator *ldo;
186 ldo = regulator_get(NULL, "ldo6"); //vcc_33
187 regulator_set_voltage(ldo, 3300000, 3300000);
188 regulator_set_suspend_voltage(ldo, 3300000);
189 regulator_enable(ldo);
190 // printk("%s set ldo6 vcc_33=%dmV end\n", __func__, regulator_get_voltage(ldo));
194 ldo = regulator_get(NULL, "ldo4"); // vdd_11
195 regulator_set_voltage(ldo, 1100000, 1100000);
196 regulator_set_suspend_voltage(ldo, 1000000);
197 regulator_enable(ldo);
198 // printk("%s set ldo4 vdd_11=%dmV end\n", __func__, regulator_get_voltage(ldo));
202 ldo = regulator_get(NULL, "ldo5"); //vcc_25
203 regulator_set_voltage(ldo, 2500000, 2500000);
204 regulator_set_suspend_voltage(ldo, 2500000);
205 regulator_enable(ldo);
206 // printk("%s set ldo5 vcc_25=%dmV end\n", __func__, regulator_get_voltage(ldo));
209 dcdc = regulator_get(NULL, "dcdc4"); // vcc_io
210 #ifdef CONFIG_MACH_RK3066_SDK
211 regulator_set_voltage(dcdc, 3300000, 3300000);
212 regulator_set_suspend_voltage(dcdc, 3100000);
214 regulator_set_voltage(dcdc, 3000000, 3000000);
215 regulator_set_suspend_voltage(dcdc, 2800000);
217 regulator_enable(dcdc);
218 // printk("%s set dcdc4 vcc_io=%dmV end\n", __func__, regulator_get_voltage(dcdc));
222 dcdc = regulator_get(NULL, "vdd_cpu"); // vdd_arm
223 regulator_set_voltage(dcdc, 1100000, 1100000);
224 regulator_set_suspend_voltage(dcdc, 1000000);
225 regulator_enable(dcdc);
226 printk("%s set dcdc2 vdd_cpu(vdd_arm)=%dmV end\n", __func__, regulator_get_voltage(dcdc));
230 dcdc = regulator_get(NULL, "vdd_core"); // vdd_log
232 /* Read avs value under logic 1.1V*/
233 regulator_set_voltage(dcdc, 1100000, 1100000);
234 avs_init_val_get(1,1100000,"wm8326 init");
236 avs_set_scal_val(AVS_BASE);
238 regulator_set_voltage(dcdc, 1150000, 1150000);
239 regulator_set_suspend_voltage(dcdc, 1000000);
240 regulator_enable(dcdc);
241 printk("%s set dcdc1 vdd_core(vdd_log)=%dmV end\n", __func__, regulator_get_voltage(dcdc));
245 dcdc = regulator_get(NULL, "dcdc3"); // vcc_ddr
246 regulator_set_voltage(dcdc, 1150000, 1150000);
247 regulator_set_suspend_voltage(dcdc, 1150000);
248 regulator_enable(dcdc);
249 // printk("%s set dcdc3 vcc_ddr=%dmV end\n", __func__, regulator_get_voltage(dcdc));
253 ldo = regulator_get(NULL, "ldo7"); // vcc28_cif
254 regulator_set_voltage(ldo, 2800000, 2800000);
255 regulator_set_suspend_voltage(ldo, 2800000);
256 regulator_enable(ldo);
257 // printk("%s set ldo7 vcc28_cif=%dmV end\n", __func__, regulator_get_voltage(ldo));
261 ldo = regulator_get(NULL, "ldo1"); // vcc18_cif
262 regulator_set_voltage(ldo, 1800000, 1800000);
263 regulator_set_suspend_voltage(ldo, 1800000);
264 regulator_enable(ldo);
265 // printk("%s set ldo1 vcc18_cif=%dmV end\n", __func__, regulator_get_voltage(ldo));
269 ldo = regulator_get(NULL, "ldo8"); // vcca_33
270 regulator_set_voltage(ldo, 3300000, 3300000);
271 regulator_set_suspend_voltage(ldo, 3300000);
272 regulator_enable(ldo);
273 // printk("%s set ldo8 vcca_33=%dmV end\n", __func__, regulator_get_voltage(ldo));
277 ldo = regulator_get(NULL, "ldo2"); //vccio_wl
278 regulator_set_voltage(ldo, 1800000, 1800000);
279 regulator_set_suspend_voltage(ldo, 1800000);
280 regulator_enable(ldo);
281 // printk("%s set ldo2 vccio_wl=%dmV end\n", __func__, regulator_get_voltage(ldo));
285 ldo = regulator_get(NULL, "ldo10"); //flash io
286 regulator_set_voltage(ldo, 1800000, 1800000);
287 regulator_set_suspend_voltage(ldo, 1800000);
288 regulator_enable(ldo);
289 // printk("%s set ldo10 vcca_wl=%dmV end\n", __func__, regulator_get_voltage(ldo));
293 #ifdef CONFIG_MACH_RK3066_SDK
294 ldo = regulator_get(NULL, "ldo3"); //vdd11_hdmi
295 regulator_set_voltage(ldo, 1100000, 1100000);
296 regulator_set_suspend_voltage(ldo, 1100000);
298 ldo = regulator_get(NULL, "ldo3"); //vdd_12
299 regulator_set_voltage(ldo, 1200000, 1200000);
300 regulator_set_suspend_voltage(ldo, 1200000);
302 regulator_enable(ldo);
303 // printk("%s set ldo3 vdd_12=%dmV end\n", __func__, regulator_get_voltage(ldo));
307 ldo = regulator_get(NULL, "ldo9"); //vcc_tp
308 regulator_set_voltage(ldo, 3300000, 3300000);
309 regulator_set_suspend_voltage(ldo, 3300000);
310 regulator_enable(ldo);
311 // printk("%s set ldo9 vcc_tp=%dmV end\n", __func__, regulator_get_voltage(ldo));
315 wm831x_mask_interrupt(Wm831x);
317 #ifdef CONFIG_WM8326_VBAT_LOW_DETECTION
318 wm831x_low_power_detection(Wm831x);
321 printk("wm831x_post_init end");
325 static int wm831x_last_deinit(struct wm831x *Wm831x)
327 struct regulator *ldo;
329 printk("%s\n", __func__);
330 ldo = regulator_get(NULL, "ldo1");
331 regulator_disable(ldo);
334 ldo = regulator_get(NULL, "ldo2");
335 regulator_disable(ldo);
338 ldo = regulator_get(NULL, "ldo3");
339 regulator_disable(ldo);
342 ldo = regulator_get(NULL, "ldo4");
343 //regulator_disable(ldo);
346 ldo = regulator_get(NULL, "ldo5");
347 // regulator_disable(ldo);
350 ldo = regulator_get(NULL, "ldo6");
351 // regulator_disable(ldo);
354 ldo = regulator_get(NULL, "ldo7");
355 regulator_disable(ldo);
358 ldo = regulator_get(NULL, "ldo8");
359 regulator_disable(ldo);
362 ldo = regulator_get(NULL, "ldo9");
363 regulator_disable(ldo);
366 ldo = regulator_get(NULL, "ldo10");
367 regulator_disable(ldo);
373 struct wm831x_status_pdata wm831x_status_platdata[WM831X_MAX_STATUS] = {
375 .default_src = WM831X_STATUS_OTP,
376 .name = "wm831x_status0",
377 .default_trigger = "wm831x_otp",
380 .default_src = WM831X_STATUS_POWER,
381 .name = "wm831x_status1",
382 .default_trigger = "wm831x_power",
386 static struct regulator_consumer_supply dcdc1_consumers[] = {
388 .supply = "vdd_core",
392 static struct regulator_consumer_supply dcdc2_consumers[] = {
399 static struct regulator_consumer_supply dcdc3_consumers[] = {
405 static struct regulator_consumer_supply dcdc4_consumers[] = {
412 static struct regulator_consumer_supply epe1_consumers[] = {
418 static struct regulator_consumer_supply epe2_consumers[] = {
425 static struct regulator_consumer_supply ldo1_consumers[] = {
431 static struct regulator_consumer_supply ldo2_consumers[] = {
437 static struct regulator_consumer_supply ldo3_consumers[] = {
443 static struct regulator_consumer_supply ldo4_consumers[] = {
449 static struct regulator_consumer_supply ldo5_consumers[] = {
455 static struct regulator_consumer_supply ldo6_consumers[] = {
461 static struct regulator_consumer_supply ldo7_consumers[] = {
467 static struct regulator_consumer_supply ldo8_consumers[] = {
473 static struct regulator_consumer_supply ldo9_consumers[] = {
479 static struct regulator_consumer_supply ldo10_consumers[] = {
485 static struct regulator_consumer_supply ldo11_consumers[] = {
491 struct regulator_init_data wm831x_regulator_init_dcdc[WM831X_MAX_DCDC] = {
496 .max_uV = 1800000, //0.6-1.8V
498 .valid_ops_mask = REGULATOR_CHANGE_STATUS | REGULATOR_CHANGE_VOLTAGE,
500 .num_consumer_supplies = ARRAY_SIZE(dcdc1_consumers),
501 .consumer_supplies = dcdc1_consumers,
507 .max_uV = 1800000, //0.6-1.8V
509 .valid_ops_mask = REGULATOR_CHANGE_STATUS | REGULATOR_CHANGE_VOLTAGE,
511 .num_consumer_supplies = ARRAY_SIZE(dcdc2_consumers),
512 .consumer_supplies = dcdc2_consumers,
518 .max_uV = 3400000, //0.85-3.4V
520 .valid_ops_mask = REGULATOR_CHANGE_STATUS | REGULATOR_CHANGE_VOLTAGE,
522 .num_consumer_supplies = ARRAY_SIZE(dcdc3_consumers),
523 .consumer_supplies = dcdc3_consumers,
529 .max_uV = 3400000, //0.85-3.4V
531 .valid_ops_mask = REGULATOR_CHANGE_STATUS | REGULATOR_CHANGE_VOLTAGE,
533 .num_consumer_supplies = ARRAY_SIZE(dcdc4_consumers),
534 .consumer_supplies = dcdc4_consumers,
539 struct regulator_init_data wm831x_regulator_init_epe[WM831X_MAX_EPE] = {
546 .valid_ops_mask = REGULATOR_CHANGE_STATUS | REGULATOR_CHANGE_VOLTAGE,
548 .num_consumer_supplies = ARRAY_SIZE(epe1_consumers),
549 .consumer_supplies = epe1_consumers,
557 .valid_ops_mask = REGULATOR_CHANGE_STATUS | REGULATOR_CHANGE_VOLTAGE,
559 .num_consumer_supplies = ARRAY_SIZE(epe2_consumers),
560 .consumer_supplies = epe2_consumers,
565 struct regulator_init_data wm831x_regulator_init_ldo[WM831X_MAX_LDO] = {
572 .valid_ops_mask = REGULATOR_CHANGE_STATUS | REGULATOR_CHANGE_VOLTAGE,
574 .num_consumer_supplies = ARRAY_SIZE(ldo1_consumers),
575 .consumer_supplies = ldo1_consumers,
583 .valid_ops_mask = REGULATOR_CHANGE_STATUS | REGULATOR_CHANGE_VOLTAGE,
585 .num_consumer_supplies = ARRAY_SIZE(ldo2_consumers),
586 .consumer_supplies = ldo2_consumers,
594 .valid_ops_mask = REGULATOR_CHANGE_STATUS | REGULATOR_CHANGE_VOLTAGE,
596 .num_consumer_supplies = ARRAY_SIZE(ldo3_consumers),
597 .consumer_supplies = ldo3_consumers,
605 .valid_ops_mask = REGULATOR_CHANGE_STATUS | REGULATOR_CHANGE_VOLTAGE,
607 .num_consumer_supplies = ARRAY_SIZE(ldo4_consumers),
608 .consumer_supplies = ldo4_consumers,
616 .valid_ops_mask = REGULATOR_CHANGE_STATUS | REGULATOR_CHANGE_VOLTAGE,
618 .num_consumer_supplies = ARRAY_SIZE(ldo5_consumers),
619 .consumer_supplies = ldo5_consumers,
627 .valid_ops_mask = REGULATOR_CHANGE_STATUS | REGULATOR_CHANGE_VOLTAGE,
629 .num_consumer_supplies = ARRAY_SIZE(ldo6_consumers),
630 .consumer_supplies = ldo6_consumers,
638 .valid_ops_mask = REGULATOR_CHANGE_STATUS | REGULATOR_CHANGE_VOLTAGE,
640 .num_consumer_supplies = ARRAY_SIZE(ldo7_consumers),
641 .consumer_supplies = ldo7_consumers,
649 .valid_ops_mask = REGULATOR_CHANGE_STATUS | REGULATOR_CHANGE_VOLTAGE,
651 .num_consumer_supplies = ARRAY_SIZE(ldo8_consumers),
652 .consumer_supplies = ldo8_consumers,
660 .valid_ops_mask = REGULATOR_CHANGE_STATUS | REGULATOR_CHANGE_VOLTAGE,
662 .num_consumer_supplies = ARRAY_SIZE(ldo9_consumers),
663 .consumer_supplies = ldo9_consumers,
671 .valid_ops_mask = REGULATOR_CHANGE_STATUS | REGULATOR_CHANGE_VOLTAGE,
673 .num_consumer_supplies = ARRAY_SIZE(ldo10_consumers),
674 .consumer_supplies = ldo10_consumers,
682 .valid_ops_mask = REGULATOR_CHANGE_STATUS | REGULATOR_CHANGE_VOLTAGE,
684 .num_consumer_supplies = ARRAY_SIZE(ldo11_consumers),
685 .consumer_supplies = ldo11_consumers,
689 static int wm831x_init_pin_type(struct wm831x *wm831x)
691 struct wm831x_pdata *pdata;
692 struct rk29_gpio_expander_info *wm831x_gpio_settinginfo;
693 uint16_t wm831x_settingpin_num;
696 if (!wm831x || !wm831x->dev)
699 pdata = wm831x->dev->platform_data;
703 wm831x_gpio_settinginfo = pdata->settinginfo;
704 if (!wm831x_gpio_settinginfo)
707 wm831x_settingpin_num = pdata->settinginfolen;
708 for (i = 0; i < wm831x_settingpin_num; i++) {
709 if (wm831x_gpio_settinginfo[i].pin_type == GPIO_IN) {
710 wm831x_set_bits(wm831x,
711 WM831X_GPIO1_CONTROL + i,
712 WM831X_GPN_DIR_MASK | WM831X_GPN_TRI_MASK,
713 1 << WM831X_GPN_DIR_SHIFT | 1 << WM831X_GPN_TRI_SHIFT);
715 wm831x_set_bits(wm831x,
716 WM831X_GPIO1_CONTROL + i,
719 wm831x_set_bits(wm831x,
720 WM831X_GPIO1_CONTROL + i,
723 } // set gpio2 sleep/wakeup
726 wm831x_set_bits(wm831x,
727 WM831X_GPIO1_CONTROL + i,
728 WM831X_GPN_PULL_MASK,
729 0x0000); //disable pullup/down
730 wm831x_set_bits(wm831x,
731 WM831X_GPIO1_CONTROL + i,
732 WM831X_GPN_PWR_DOM_MASK,
734 wm831x_set_bits(wm831x,
735 WM831X_GPIO1_CONTROL + i,
738 } //set gpio10 as adc input
741 wm831x_set_bits(wm831x,
742 WM831X_GPIO1_CONTROL + i,
743 WM831X_GPN_DIR_MASK | WM831X_GPN_TRI_MASK,
744 1 << WM831X_GPN_TRI_SHIFT);
745 if (wm831x_gpio_settinginfo[i].pin_value == GPIO_HIGH) {
746 wm831x_set_bits(wm831x, WM831X_GPIO_LEVEL, 1 << i, 1 << i);
748 wm831x_set_bits(wm831x, WM831X_GPIO_LEVEL, 1 << i, 0 << i);
751 wm831x_set_bits(wm831x,
752 WM831X_GPIO1_CONTROL + i,
753 WM831X_GPN_PWR_DOM_MASK | WM831X_GPN_POL_MASK |WM831X_GPN_FN_MASK,
754 1 << WM831X_GPN_POL_SHIFT | 1 << WM831X_GPN_PWR_DOM_SHIFT | 1 << 0);
756 } // set gpio3 as clkout output 32.768K
762 for (i = 0; i < pdata->gpio_pin_num; i++) {
763 wm831x_set_bits(wm831x,
764 WM831X_GPIO1_CONTROL + i,
765 WM831X_GPN_PULL_MASK | WM831X_GPN_POL_MASK | WM831X_GPN_OD_MASK | WM831X_GPN_TRI_MASK,
766 1 << WM831X_GPN_POL_SHIFT | 1 << WM831X_GPN_TRI_SHIFT);
768 ret = wm831x_reg_read(wm831x, WM831X_GPIO1_CONTROL + i);
769 printk("Gpio%d Pin Configuration = %x\n", i, ret);
777 void __sramfunc board_pmu_suspend(void)
779 cru_writel(CRU_CLKGATE5_GRFCLK_ON,CRU_CLKGATE5_CON_ADDR); //open grf clk
780 grf_writel(GPIO6_PB1_DIR_OUT, GRF_GPIO6L_DIR_ADDR);
781 grf_writel(GPIO6_PB1_DO_HIGH, GRF_GPIO6L_DO_ADDR); //set gpio6_b1 output low
782 grf_writel(GPIO6_PB1_EN_MASK, GRF_GPIO6L_EN_ADDR);
784 void __sramfunc board_pmu_resume(void)
786 grf_writel(GPIO6_PB1_DIR_OUT, GRF_GPIO6L_DIR_ADDR);
787 grf_writel(GPIO6_PB1_DO_LOW, GRF_GPIO6L_DO_ADDR); //set gpio6_b1 output high
788 grf_writel(GPIO6_PB1_EN_MASK, GRF_GPIO6L_EN_ADDR);
789 #ifdef CONFIG_CLK_SWITCH_TO_32K
790 sram_32k_udelay(10000);
795 static struct wm831x_pdata wm831x_platdata = {
797 /** Called before subdevices are set up */
798 .pre_init = wm831x_pre_init,
799 /** Called after subdevices are set up */
800 .post_init = wm831x_post_init,
801 /** Called before subdevices are power down */
802 .last_deinit = wm831x_last_deinit,
804 #if defined(CONFIG_GPIO_WM831X)
805 .gpio_base = WM831X_GPIO_EXPANDER_BASE,
806 .gpio_pin_num = WM831X_TOTOL_GPIO_NUM,
807 .settinginfo = wm831x_gpio_settinginfo,
808 .settinginfolen = ARRAY_SIZE(wm831x_gpio_settinginfo),
809 .pin_type_init = wm831x_init_pin_type,
810 .irq_base = IRQ_BOARD_BASE,
813 /** LED1 = 0 and so on */
814 .status = { &wm831x_status_platdata[0], &wm831x_status_platdata[1] },
816 /** DCDC1 = 0 and so on */
818 &wm831x_regulator_init_dcdc[0],
819 &wm831x_regulator_init_dcdc[1],
820 &wm831x_regulator_init_dcdc[2],
821 &wm831x_regulator_init_dcdc[3],
824 /** EPE1 = 0 and so on */
825 //.epe = { &wm831x_regulator_init_epe[0], &wm831x_regulator_init_epe[1] },
827 /** LDO1 = 0 and so on */
829 &wm831x_regulator_init_ldo[0],
830 &wm831x_regulator_init_ldo[1],
831 &wm831x_regulator_init_ldo[2],
832 &wm831x_regulator_init_ldo[3],
833 &wm831x_regulator_init_ldo[4],
834 &wm831x_regulator_init_ldo[5],
835 &wm831x_regulator_init_ldo[6],
836 &wm831x_regulator_init_ldo[7],
837 &wm831x_regulator_init_ldo[8],
838 &wm831x_regulator_init_ldo[9],
839 &wm831x_regulator_init_ldo[10],