These patches against the regulator tree add initial support for the
WM8350, a multi-function device with several subsystems targetted at
embedded systems. This series adds a core driver providing device acess
under drivers/mfd and support for the PMIC functionality of the device
via the regulator API. Due to their use in the core some definitions
for other parts of the device are also included - drivers for these will
follow.
All the WM8350 drivers submitted here were originally written by Liam
Girdwood with some updates from me for submission to mainline.
Samuel, as with the WM8400 are you OK with merging this via the
regulator tree?
The following changes since commit fcbd54dd718e6741b05f8e5b08cbc75548acf0e4:
Mark Brown (1):
regulator: Add WM8400 regulator support
are available in the git repository at:
git://opensource.wolfsonmicro.com/linux-2.6-audioplus for-lrg
Mark Brown (13):
mfd: Add WM8350 audio register definitions
mfd: Add WM8350 GPIO register definitions
mfd: Add WM8350 PMIC register definitions
mfd: Add WM8350 PMU register definitions
mfd: Add WM8350 comparator register definitions
mfd: Add WM8350 RTC register definitions
mfd: Add WM8350 watchdog register definitions
mfd: Core support for the WM8350 AudioPlus PMIC
mfd: Add I2C control support for WM8350
mfd: Add GPIO pin configuration support for WM8350
mfd: Add initialisation callback for WM8350
mfd: Add WM8350 interrupt support
regulator: Add WM8350 regulator support
drivers/mfd/Kconfig | 58 ++
drivers/mfd/Makefile | 3 +
drivers/mfd/wm8350-core.c | 1239 ++++++++++++++++++++++++++++
drivers/mfd/wm8350-gpio.c | 222 +++++
drivers/mfd/wm8350-i2c.c | 120 +++
drivers/mfd/wm8350-regmap.c | 1323 ++++++++++++++++++++++++++++++
drivers/regulator/Kconfig | 10 +
drivers/regulator/Makefile | 1 ...Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com> --- include/linux/mfd/wm8350/audio.h | 592 ++++++++++++++++++++++++++++++++++++++ 1 files changed, 592 insertions(+), 0 deletions(-) create mode 100644 include/linux/mfd/wm8350/audio.h diff --git a/include/linux/mfd/wm8350/audio.h b/include/linux/mfd/wm8350/audio.h new file mode 100644 index 0000000..43342f7 --- /dev/null +++ b/include/linux/mfd/wm8350/audio.h @@ -0,0 +1,592 @@ +/* + * audio.h -- Audio Driver for Wolfson WM8350 PMIC + * + * Copyright 2007 Wolfson Microelectronics PLC + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the + * Free Software Foundation; either version 2 of the License, or (at your + * option) any later version. + * + */ + +#ifndef __LINUX_MFD_WM8350_AUDIO_H_ +#define __LINUX_MFD_WM8350_AUDIO_H_ + +#define WM8350_CLOCK_CONTROL_1 0x28 +#define WM8350_CLOCK_CONTROL_2 0x29 +#define WM8350_FLL_CONTROL_1 0x2A +#define WM8350_FLL_CONTROL_2 0x2B +#define WM8350_FLL_CONTROL_3 0x2C +#define WM8350_FLL_CONTROL_4 0x2D +#define WM8350_DAC_CONTROL 0x30 +#define WM8350_DAC_DIGITAL_VOLUME_L 0x32 +#define WM8350_DAC_DIGITAL_VOLUME_R 0x33 +#define WM8350_DAC_LR_RATE 0x35 +#define WM8350_DAC_CLOCK_CONTROL 0x36 +#define WM8350_DAC_MUTE 0x3A +#define WM8350_DAC_MUTE_VOLUME 0x3B +#define WM8350_DAC_SIDE 0x3C +#define WM8350_ADC_CONTROL 0x40 +#define WM8350_ADC_DIGITAL_VOLUME_L 0x42 +#define WM8350_ADC_DIGITAL_VOLUME_R 0x43 +#define WM8350_ADC_DIVIDER 0x44 +#define WM8350_ADC_LR_RATE 0x46 +#define WM8350_INPUT_CONTROL ...
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com> --- include/linux/mfd/wm8350/gpio.h | 326 +++++++++++++++++++++++++++++++++++++++ 1 files changed, 326 insertions(+), 0 deletions(-) create mode 100644 include/linux/mfd/wm8350/gpio.h diff --git a/include/linux/mfd/wm8350/gpio.h b/include/linux/mfd/wm8350/gpio.h new file mode 100644 index 0000000..928aa6e --- /dev/null +++ b/include/linux/mfd/wm8350/gpio.h @@ -0,0 +1,326 @@ +/* + * gpio.h -- GPIO Driver for Wolfson WM8350 PMIC + * + * Copyright 2007 Wolfson Microelectronics PLC + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the + * Free Software Foundation; either version 2 of the License, or (at your + * option) any later version. + * + */ + +#ifndef __LINUX_MFD_WM8350_GPIO_H_ +#define __LINUX_MFD_WM8350_GPIO_H_ + +/* + * GPIO Registers. + */ +#define WM8350_GPIO_DEBOUNCE 0x80 +#define WM8350_GPIO_PIN_PULL_UP_CONTROL 0x81 +#define WM8350_GPIO_PULL_DOWN_CONTROL 0x82 +#define WM8350_GPIO_INT_MODE 0x83 +#define WM8350_GPIO_CONTROL 0x85 +#define WM8350_GPIO_CONFIGURATION_I_O 0x86 +#define WM8350_GPIO_PIN_POLARITY_TYPE 0x87 +#define WM8350_GPIO_FUNCTION_SELECT_1 0x8C +#define WM8350_GPIO_FUNCTION_SELECT_2 0x8D +#define WM8350_GPIO_FUNCTION_SELECT_3 0x8E +#define WM8350_GPIO_FUNCTION_SELECT_4 0x8F + +/* + * GPIO Functions + */ +#define WM8350_GPIO0_GPIO_IN 0x0 +#define WM8350_GPIO0_GPIO_OUT 0x0 +#define WM8350_GPIO0_PWR_ON_IN 0x1 +#define WM8350_GPIO0_PWR_ON_OUT 0x1 +#define WM8350_GPIO0_LDO_EN_IN 0x2 +#define WM8350_GPIO0_VRTC_OUT 0x2 +#define WM8350_GPIO0_LPWR1_IN 0x3 +#define WM8350_GPIO0_POR_B_OUT 0x3 + +#define WM8350_GPIO1_GPIO_IN 0x0 +#define WM8350_GPIO1_GPIO_OUT 0x0 +#define WM8350_GPIO1_PWR_ON_IN 0x1 +#define ...
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com> --- include/linux/mfd/wm8350/pmic.h | 699 +++++++++++++++++++++++++++++++++++++++ 1 files changed, 699 insertions(+), 0 deletions(-) create mode 100644 include/linux/mfd/wm8350/pmic.h diff --git a/include/linux/mfd/wm8350/pmic.h b/include/linux/mfd/wm8350/pmic.h new file mode 100644 index 0000000..28d2fab --- /dev/null +++ b/include/linux/mfd/wm8350/pmic.h @@ -0,0 +1,699 @@ +/* + * pmic.h -- Power Managment Driver for Wolfson WM8350 PMIC + * + * Copyright 2007 Wolfson Microelectronics PLC + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the + * Free Software Foundation; either version 2 of the License, or (at your + * option) any later version. + * + */ + +#ifndef __LINUX_MFD_WM8350_PMIC_H +#define __LINUX_MFD_WM8350_PMIC_H + +/* + * Register values. + */ + +#define WM8350_CURRENT_SINK_DRIVER_A 0xAC +#define WM8350_CSA_FLASH_CONTROL 0xAD +#define WM8350_CURRENT_SINK_DRIVER_B 0xAE +#define WM8350_CSB_FLASH_CONTROL 0xAF +#define WM8350_DCDC_LDO_REQUESTED 0xB0 +#define WM8350_DCDC_ACTIVE_OPTIONS 0xB1 +#define WM8350_DCDC_SLEEP_OPTIONS 0xB2 +#define WM8350_POWER_CHECK_COMPARATOR 0xB3 +#define WM8350_DCDC1_CONTROL 0xB4 +#define WM8350_DCDC1_TIMEOUTS 0xB5 +#define WM8350_DCDC1_LOW_POWER 0xB6 +#define WM8350_DCDC2_CONTROL 0xB7 +#define WM8350_DCDC2_TIMEOUTS 0xB8 +#define WM8350_DCDC3_CONTROL 0xBA +#define WM8350_DCDC3_TIMEOUTS 0xBB +#define WM8350_DCDC3_LOW_POWER 0xBC +#define WM8350_DCDC4_CONTROL 0xBD +#define WM8350_DCDC4_TIMEOUTS 0xBE +#define WM8350_DCDC4_LOW_POWER 0xBF +#define ...
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com> --- include/linux/mfd/wm8350/supply.h | 105 +++++++++++++++++++++++++++++++++++++ 1 files changed, 105 insertions(+), 0 deletions(-) create mode 100644 include/linux/mfd/wm8350/supply.h diff --git a/include/linux/mfd/wm8350/supply.h b/include/linux/mfd/wm8350/supply.h new file mode 100644 index 0000000..f1d4317 --- /dev/null +++ b/include/linux/mfd/wm8350/supply.h @@ -0,0 +1,105 @@ +/* + * supply.h -- Power Supply Driver for Wolfson WM8350 PMIC + * + * Copyright 2007 Wolfson Microelectronics PLC + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the + * Free Software Foundation; either version 2 of the License, or (at your + * option) any later version. + * + */ + +#ifndef __LINUX_MFD_WM8350_SUPPLY_H_ +#define __LINUX_MFD_WM8350_SUPPLY_H_ + +/* + * Charger registers + */ +#define WM8350_BATTERY_CHARGER_CONTROL_1 0xA8 +#define WM8350_BATTERY_CHARGER_CONTROL_2 0xA9 +#define WM8350_BATTERY_CHARGER_CONTROL_3 0xAA + +/* + * R168 (0xA8) - Battery Charger Control 1 + */ +#define WM8350_CHG_ENA_R168 0x8000 +#define WM8350_CHG_THR 0x2000 +#define WM8350_CHG_EOC_SEL_MASK 0x1C00 +#define WM8350_CHG_TRICKLE_TEMP_CHOKE 0x0200 +#define WM8350_CHG_TRICKLE_USB_CHOKE 0x0100 +#define WM8350_CHG_RECOVER_T 0x0080 +#define WM8350_CHG_END_ACT 0x0040 +#define WM8350_CHG_FAST 0x0020 +#define WM8350_CHG_FAST_USB_THROTTLE 0x0010 +#define WM8350_CHG_NTC_MON 0x0008 +#define WM8350_CHG_BATT_HOT_MON 0x0004 +#define WM8350_CHG_BATT_COLD_MON 0x0002 +#define WM8350_CHG_CHIP_TEMP_MON 0x0001 + +/* + * R169 (0xA9) - Battery Charger Control 2 + */ +#define WM8350_CHG_ACTIVE ...
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com> --- include/linux/mfd/wm8350/comparator.h | 167 +++++++++++++++++++++++++++++++++ 1 files changed, 167 insertions(+), 0 deletions(-) create mode 100644 include/linux/mfd/wm8350/comparator.h diff --git a/include/linux/mfd/wm8350/comparator.h b/include/linux/mfd/wm8350/comparator.h new file mode 100644 index 0000000..0537886 --- /dev/null +++ b/include/linux/mfd/wm8350/comparator.h @@ -0,0 +1,167 @@ +/* + * comparator.h -- Comparator Aux ADC for Wolfson WM8350 PMIC + * + * Copyright 2007 Wolfson Microelectronics PLC + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the + * Free Software Foundation; either version 2 of the License, or (at your + * option) any later version. + */ + +#ifndef __LINUX_MFD_WM8350_COMPARATOR_H_ +#define __LINUX_MFD_WM8350_COMPARATOR_H_ + +/* + * Registers + */ + +#define WM8350_DIGITISER_CONTROL_1 0x90 +#define WM8350_DIGITISER_CONTROL_2 0x91 +#define WM8350_AUX1_READBACK 0x98 +#define WM8350_AUX2_READBACK 0x99 +#define WM8350_AUX3_READBACK 0x9A +#define WM8350_AUX4_READBACK 0x9B +#define WM8350_CHIP_TEMP_READBACK 0x9F +#define WM8350_GENERIC_COMPARATOR_CONTROL 0xA3 +#define WM8350_GENERIC_COMPARATOR_1 0xA4 +#define WM8350_GENERIC_COMPARATOR_2 0xA5 +#define WM8350_GENERIC_COMPARATOR_3 0xA6 +#define WM8350_GENERIC_COMPARATOR_4 0xA7 + +/* + * R144 (0x90) - Digitiser Control (1) + */ +#define WM8350_AUXADC_CTC 0x4000 +#define WM8350_AUXADC_POLL 0x2000 +#define WM8350_AUXADC_HIB_MODE 0x1000 +#define WM8350_AUXADC_SEL8 0x0080 +#define WM8350_AUXADC_SEL7 0x0040 +#define WM8350_AUXADC_SEL6 ...
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com> --- include/linux/mfd/wm8350/rtc.h | 260 ++++++++++++++++++++++++++++++++++++++++ 1 files changed, 260 insertions(+), 0 deletions(-) create mode 100644 include/linux/mfd/wm8350/rtc.h diff --git a/include/linux/mfd/wm8350/rtc.h b/include/linux/mfd/wm8350/rtc.h new file mode 100644 index 0000000..cb337ea --- /dev/null +++ b/include/linux/mfd/wm8350/rtc.h @@ -0,0 +1,260 @@ +/* + * rtc.h -- RTC driver for Wolfson WM8350 PMIC + * + * Copyright 2007 Wolfson Microelectronics PLC + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the + * Free Software Foundation; either version 2 of the License, or (at your + * option) any later version. + */ + +#ifndef __LINUX_MFD_WM8350_RTC_H +#define __LINUX_MFD_WM8350_RTC_H + +/* + * Register values. + */ +#define WM8350_RTC_SECONDS_MINUTES 0x10 +#define WM8350_RTC_HOURS_DAY 0x11 +#define WM8350_RTC_DATE_MONTH 0x12 +#define WM8350_RTC_YEAR 0x13 +#define WM8350_ALARM_SECONDS_MINUTES 0x14 +#define WM8350_ALARM_HOURS_DAY 0x15 +#define WM8350_ALARM_DATE_MONTH 0x16 +#define WM8350_RTC_TIME_CONTROL 0x17 + +/* + * R16 (0x10) - RTC Seconds/Minutes + */ +#define WM8350_RTC_MINS_MASK 0x7F00 +#define WM8350_RTC_MINS_SHIFT 8 +#define WM8350_RTC_SECS_MASK 0x007F +#define WM8350_RTC_SECS_SHIFT 0 + +/* + * R17 (0x11) - RTC Hours/Day + */ +#define WM8350_RTC_DAY_MASK 0x0700 +#define WM8350_RTC_DAY_SHIFT 8 +#define WM8350_RTC_HPM_MASK 0x0020 +#define WM8350_RTC_HPM_SHIFT 5 +#define WM8350_RTC_HRS_MASK 0x001F +#define WM8350_RTC_HRS_SHIFT ...
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com> --- include/linux/mfd/wm8350/wdt.h | 22 ++++++++++++++++++++++ 1 files changed, 22 insertions(+), 0 deletions(-) create mode 100644 include/linux/mfd/wm8350/wdt.h diff --git a/include/linux/mfd/wm8350/wdt.h b/include/linux/mfd/wm8350/wdt.h new file mode 100644 index 0000000..72fc9f5 --- /dev/null +++ b/include/linux/mfd/wm8350/wdt.h @@ -0,0 +1,22 @@ +/* + * wdt.h -- Watchdog Driver for Wolfson WM8350 PMIC + * + * Copyright 2007 Wolfson Microelectronics PLC + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the + * Free Software Foundation; either version 2 of the License, or (at your + * option) any later version. + */ + +#ifndef __LINUX_MFD_WM8350_WDT_H_ +#define __LINUX_MFD_WM8350_WDT_H_ + +#define WM8350_WDOG_HIB_MODE 0x0080 +#define WM8350_WDOG_DEBUG 0x0040 +#define WM8350_WDOG_MODE_MASK 0x0030 +#define WM8350_WDOG_TO_MASK 0x0007 + +#define WM8350_IRQ_SYS_WDOG_TO 24 + +#endif -- 1.5.6.5 --
The WM8350 is an integrated audio and power management subsystem intended for use as the primary PMIC in mobile multimedia applications. The WM8350 can be controlled via either I2C or SPI - the control interface is provided by a separate module in order to allow greatest flexibility in configuring the kernel. This driver was originally written by Liam Girdwood and has since been updated to current kernel APIs and split up for submission by me. All the heavy lifting here was done by Liam. Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com> --- drivers/mfd/Kconfig | 47 ++ drivers/mfd/Makefile | 2 + drivers/mfd/wm8350-core.c | 456 ++++++++++++++ drivers/mfd/wm8350-regmap.c | 1323 +++++++++++++++++++++++++++++++++++++++ include/linux/mfd/wm8350/core.h | 585 +++++++++++++++++ 5 files changed, 2413 insertions(+), 0 deletions(-) create mode 100644 drivers/mfd/wm8350-core.c create mode 100644 drivers/mfd/wm8350-regmap.c create mode 100644 include/linux/mfd/wm8350/core.h diff --git a/drivers/mfd/Kconfig b/drivers/mfd/Kconfig index 0541dfb..c32d676 100644 --- a/drivers/mfd/Kconfig +++ b/drivers/mfd/Kconfig @@ -86,6 +86,53 @@ config MFD_WM8400 the device, additional drivers must be enabled in order to use the functionality of the device. +config MFD_WM8350 + tristate + +config MFD_WM8350_CONFIG_MODE_0 + bool "Support WM8350 in configuration mode 0" + depends on MFD_WM8350 + default y + help + The WM8350 offers four configuration modes with different + initial register states. This option enables support for the + WM8350 in mode 0. + + If unsure say Y + +config MFD_WM8350_CONFIG_MODE_1 + bool "Support WM8350 in configuration mode 1" + depends on MFD_WM8350 + default y + help + The WM8350 offers four configuration modes with different + initial register states. This option enables support for the + WM8350 in mode 1. + + If unsure say Y + +config ...
Implement the I2C control interface for the WM8350. This code was originally written by Liam Girdwood and has been updated for submission by Mark Brown. Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com> --- drivers/mfd/Kconfig | 11 ++++ drivers/mfd/Makefile | 1 + drivers/mfd/wm8350-i2c.c | 120 ++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 132 insertions(+), 0 deletions(-) create mode 100644 drivers/mfd/wm8350-i2c.c diff --git a/drivers/mfd/Kconfig b/drivers/mfd/Kconfig index c32d676..b2930cc 100644 --- a/drivers/mfd/Kconfig +++ b/drivers/mfd/Kconfig @@ -133,6 +133,17 @@ config MFD_WM8350_CONFIG_MODE_3 If unsure say Y +config MFD_WM8350_I2C + tristate "Support Wolfson Microelectronics WM8350 with I2C" + select MFD_WM8350 + depends on I2C + help + The WM8350 is an integrated audio and power management + subsystem with watchdog and RTC functionality for embedded + systems. This option enables core support for the WM8350 with + I2C as the control interface. Additional options must be + selected to enable support for the functionality of the chip. + endmenu menu "Multimedia Capabilities Port drivers" diff --git a/drivers/mfd/Makefile b/drivers/mfd/Makefile index b0adca0..746d37b 100644 --- a/drivers/mfd/Makefile +++ b/drivers/mfd/Makefile @@ -15,6 +15,7 @@ obj-$(CONFIG_MFD_TC6393XB) += tc6393xb.o obj-$(CONFIG_MFD_WM8400) += wm8400-core.o wm8350-objs := wm8350-core.o wm8350-regmap.o obj-$(CONFIG_MFD_WM8350) += wm8350.o +obj-$(CONFIG_MFD_WM8350_I2C) += wm8350-i2c.o obj-$(CONFIG_MFD_CORE) += mfd-core.o diff --git a/drivers/mfd/wm8350-i2c.c b/drivers/mfd/wm8350-i2c.c new file mode 100644 index 0000000..2b0569c --- /dev/null +++ b/drivers/mfd/wm8350-i2c.c @@ -0,0 +1,120 @@ +/* + * wm8350-i2c.c -- Generic I2C driver for Wolfson WM8350 PMIC + * + * This driver defines and configures the WM8350 for the Freescale i.MX32ADS. + * + * Copyright 2007, 2008 Wolfson ...
The WM8350 provides a number of user-configurable pins providing access to various signals generated by the functions on the chip. These are referred to as GPIO pins in the device documentation but in Linux terms they are more general than that, providing configuration of alternate functions. This patch implements support for selecting the alternate functions for these pins. They can also be used as GPIOs in the normal Linux sense - a subsequent patch will add support for doing so. This code was all written by Liam Girdwood and has had minor updates and rearrangements by Mark Brown. Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com> --- drivers/mfd/Makefile | 2 +- drivers/mfd/wm8350-gpio.c | 222 +++++++++++++++++++++++++++++++++++++++ include/linux/mfd/wm8350/gpio.h | 10 ++ 3 files changed, 233 insertions(+), 1 deletions(-) create mode 100644 drivers/mfd/wm8350-gpio.c diff --git a/drivers/mfd/Makefile b/drivers/mfd/Makefile index 746d37b..8c0b7f2 100644 --- a/drivers/mfd/Makefile +++ b/drivers/mfd/Makefile @@ -13,7 +13,7 @@ obj-$(CONFIG_MFD_TC6387XB) += tc6387xb.o obj-$(CONFIG_MFD_TC6393XB) += tc6393xb.o obj-$(CONFIG_MFD_WM8400) += wm8400-core.o -wm8350-objs := wm8350-core.o wm8350-regmap.o +wm8350-objs := wm8350-core.o wm8350-regmap.o wm8350-gpio.o obj-$(CONFIG_MFD_WM8350) += wm8350.o obj-$(CONFIG_MFD_WM8350_I2C) += wm8350-i2c.o diff --git a/drivers/mfd/wm8350-gpio.c b/drivers/mfd/wm8350-gpio.c new file mode 100644 index 0000000..ebf99be --- /dev/null +++ b/drivers/mfd/wm8350-gpio.c @@ -0,0 +1,222 @@ +/* + * wm8350-core.c -- Device access for Wolfson WM8350 + * + * Copyright 2007, 2008 Wolfson Microelectronics PLC. + * + * Author: Liam Girdwood + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the + * Free Software Foundation; either version 2 of the License, or (at your + * option) any later ...
Some functions of the WM8350 require board-specific initialisation on
startup. Provide a callback to the WM8350 driver in platform data
for platforms to use to configure the chip. Use of a callback allows
platforms to control the ordering of initialisation which can be
important.
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
---
drivers/mfd/wm8350-core.c | 12 +++++++++++-
drivers/mfd/wm8350-i2c.c | 2 +-
include/linux/mfd/wm8350/core.h | 14 +++++++++++++-
3 files changed, 25 insertions(+), 3 deletions(-)
diff --git a/drivers/mfd/wm8350-core.c b/drivers/mfd/wm8350-core.c
index c7552c0..071834b 100644
--- a/drivers/mfd/wm8350-core.c
+++ b/drivers/mfd/wm8350-core.c
@@ -388,7 +388,8 @@ out:
}
EXPORT_SYMBOL_GPL(wm8350_create_cache);
-int wm8350_device_init(struct wm8350 *wm8350)
+int wm8350_device_init(struct wm8350 *wm8350,
+ struct wm8350_platform_data *pdata)
{
int ret = -EINVAL;
u16 id1, id2, mask, mode;
@@ -439,6 +440,15 @@ int wm8350_device_init(struct wm8350 *wm8350)
return ret;
}
+ if (pdata->init) {
+ ret = pdata->init(wm8350);
+ if (ret != 0) {
+ dev_err(wm8350->dev, "Platform init() failed: %d\n",
+ ret);
+ goto err;
+ }
+ }
+
return 0;
err:
diff --git a/drivers/mfd/wm8350-i2c.c b/drivers/mfd/wm8350-i2c.c
index 2b0569c..245b790 100644
--- a/drivers/mfd/wm8350-i2c.c
+++ b/drivers/mfd/wm8350-i2c.c
@@ -65,7 +65,7 @@ static int wm8350_i2c_probe(struct i2c_client *i2c,
wm8350->read_dev = wm8350_i2c_read_device;
wm8350->write_dev = wm8350_i2c_write_device;
- ret = wm8350_device_init(wm8350);
+ ret = wm8350_device_init(wm8350, i2c->dev.platform_data);
if (ret < 0)
goto err;
diff --git a/include/linux/mfd/wm8350/core.h b/include/linux/mfd/wm8350/core.h
index 94778c1..8f2beae 100644
--- a/include/linux/mfd/wm8350/core.h
+++ b/include/linux/mfd/wm8350/core.h
@@ -564,10 +564,22 @@ struct wm8350 {
u16 *reg_cache;
};
+/**
+ * Data to be supplied by the ...The WM8350 has an interrupt line to the CPU which is shared by the
devices on the CPU. This patch adds support for the interrupt
controller within the WM8350 which identifies which identifies the
interrupt cause. In common with other similar chips this is done
outside the standard interrupt framework due to the need to access
the interrupt controller over an interrupt-driven bus.
This code was all originally written by Liam Girdwood with updates for
submission by me.
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
---
drivers/mfd/wm8350-core.c | 775 ++++++++++++++++++++++++++++++++++++++-
drivers/mfd/wm8350-i2c.c | 2 +-
include/linux/mfd/wm8350/core.h | 21 +-
3 files changed, 792 insertions(+), 6 deletions(-)
diff --git a/drivers/mfd/wm8350-core.c b/drivers/mfd/wm8350-core.c
index 071834b..f6ba9d0 100644
--- a/drivers/mfd/wm8350-core.c
+++ b/drivers/mfd/wm8350-core.c
@@ -15,15 +15,20 @@
#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/init.h>
+#include <linux/bug.h>
#include <linux/device.h>
#include <linux/delay.h>
#include <linux/interrupt.h>
+#include <linux/workqueue.h>
#include <linux/mfd/wm8350/core.h>
#include <linux/mfd/wm8350/audio.h>
+#include <linux/mfd/wm8350/comparator.h>
#include <linux/mfd/wm8350/gpio.h>
#include <linux/mfd/wm8350/pmic.h>
+#include <linux/mfd/wm8350/rtc.h>
#include <linux/mfd/wm8350/supply.h>
+#include <linux/mfd/wm8350/wdt.h>
#define WM8350_UNLOCK_KEY 0x0013
#define WM8350_LOCK_KEY 0x0000
@@ -321,6 +326,743 @@ int wm8350_reg_unlock(struct wm8350 *wm8350)
}
EXPORT_SYMBOL_GPL(wm8350_reg_unlock);
+static void wm8350_irq_call_handler(struct wm8350 *wm8350, int irq)
+{
+ mutex_lock(&wm8350->irq_mutex);
+
+ if (wm8350->irq[irq].handler)
+ wm8350->irq[irq].handler(wm8350, irq, wm8350->irq[irq].data);
+ else {
+ dev_err(wm8350->dev, "irq %d nobody cared. now masked.\n",
+ irq);
+ wm8350_mask_irq(wm8350, ...The WM8350 features six DCDC convertors (four buck and two boost), four
LDO voltage regulators and two constant current sinks. This driver adds
support for these through the regulator API.
This driver was written by Liam Girdwood with updates for submission
from Mark Brown.
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
---
drivers/mfd/wm8350-core.c | 6 +
drivers/regulator/Kconfig | 10 +
drivers/regulator/Makefile | 1 +
drivers/regulator/wm8350-regulator.c | 1430 ++++++++++++++++++++++++++++++++++
include/linux/mfd/wm8350/core.h | 5 +
include/linux/mfd/wm8350/pmic.h | 42 +
6 files changed, 1494 insertions(+), 0 deletions(-)
create mode 100644 drivers/regulator/wm8350-regulator.c
diff --git a/drivers/mfd/wm8350-core.c b/drivers/mfd/wm8350-core.c
index f6ba9d0..c7ae776 100644
--- a/drivers/mfd/wm8350-core.c
+++ b/drivers/mfd/wm8350-core.c
@@ -1223,6 +1223,12 @@ EXPORT_SYMBOL_GPL(wm8350_device_init);
void wm8350_device_exit(struct wm8350 *wm8350)
{
+ int i;
+
+ for (i = 0; i < ARRAY_SIZE(wm8350->pmic.pdev); i++)
+ if (wm8350->pmic.pdev[i] != NULL)
+ platform_device_unregister(wm8350->pmic.pdev[i]);
+
free_irq(wm8350->chip_irq, wm8350);
flush_work(&wm8350->irq_work);
kfree(wm8350->reg_cache);
diff --git a/drivers/regulator/Kconfig b/drivers/regulator/Kconfig
index 442800e..a620023 100644
--- a/drivers/regulator/Kconfig
+++ b/drivers/regulator/Kconfig
@@ -56,6 +56,14 @@ config REGULATOR_BQ24022
charging select between 100 mA and 500 mA charging current
limit.
+config REGULATOR_WM8350
+ tristate "Wolfson Microelectroncis WM8350 AudioPlus PMIC"
+ depends on MFD_WM8350
+ select REGULATOR
+ help
+ This driver provides support for the voltage and current regulators
+ of the WM8350 AudioPlus PMIC.
+
config REGULATOR_WM8400
tristate "Wolfson Microelectroncis WM8400 AudioPlus PMIC"
depends on MFD_WM8400
@@ -63,3 +71,5 @@ config REGULATOR_WM8400
...I would make the WM8350 mode configuration selectable by the target machines Kconfig rather than let the user choose. Wrong choices would Shouldn't this be #elif for each mode ? Ditto for the default register values. I would also #error if no mode was selected just to make it's correctly set by machine/board authors. Liam --
Machines can still select config modes - this just allows people to enable additional modes. That said, on reflection I can't actually see much use for that so I'll just hide the options from the user menus This is a deliberate decision in order to allow people to build kernel images supporting multiple boards - the driver will check the mode with the hardware and error out at probe time if support for the mode isn't compiled in. If the register maps were smaller I'd just compile them Yeah, that'd be nice but if the driver does that then it'll be harder for people like subsystem maintainers to do build tests with WM8350 drivers and they won't get picked up by things like allmodconfig checks. The patch below adds a build time warning for this case - the runtime checks will mean that the driver should be safe since it won't run on unknown hardware. diff --git a/drivers/mfd/Kconfig b/drivers/mfd/Kconfig index 9556547..1597c23 100644 --- a/drivers/mfd/Kconfig +++ b/drivers/mfd/Kconfig @@ -82,48 +82,20 @@ config MFD_WM8350 tristate config MFD_WM8350_CONFIG_MODE_0 - bool "Support WM8350 in configuration mode 0" + bool depends on MFD_WM8350 - default y - help - The WM8350 offers four configuration modes with different - initial register states. This option enables support for the - WM8350 in mode 0. - - If unsure say Y config MFD_WM8350_CONFIG_MODE_1 - bool "Support WM8350 in configuration mode 1" + bool depends on MFD_WM8350 - default y - help - The WM8350 offers four configuration modes with different - initial register states. This option enables support for the - WM8350 in mode 1. - - If unsure say Y config MFD_WM8350_CONFIG_MODE_2 - bool "Support WM8350 in configuration mode 2" + bool depends on MFD_WM8350 - default y - help - The WM8350 offers four configuration modes with different - initial register states. This option enables support for the - WM8350 in mode 2. - - If unsure say Y config ...
Samuel, are fine to Ack the MFD parts ? Liam --
Sorry guys, but I havent had time to look at those patches yet. Liam, when would be the last moment for me to ACK/NACK them ? I expect to be able to do so during this weekend. Cheers, -- Intel Open Source Technology Centre http://oss.intel.com/ --
I've done some updates since the original posting incorporating feedback from Liam and an update for the regulator API - do you want me to repost with those? They're sitting in: git://opensource.wolfsonmicro.com/linux-2.6-audioplus for-lrg --
Yes please. Thanks Liam --
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com> --- include/linux/mfd/wm8350/audio.h | 592 ++++++++++++++++++++++++++++++++++++++ 1 files changed, 592 insertions(+), 0 deletions(-) create mode 100644 include/linux/mfd/wm8350/audio.h diff --git a/include/linux/mfd/wm8350/audio.h b/include/linux/mfd/wm8350/audio.h new file mode 100644 index 0000000..43342f7 --- /dev/null +++ b/include/linux/mfd/wm8350/audio.h @@ -0,0 +1,592 @@ +/* + * audio.h -- Audio Driver for Wolfson WM8350 PMIC + * + * Copyright 2007 Wolfson Microelectronics PLC + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the + * Free Software Foundation; either version 2 of the License, or (at your + * option) any later version. + * + */ + +#ifndef __LINUX_MFD_WM8350_AUDIO_H_ +#define __LINUX_MFD_WM8350_AUDIO_H_ + +#define WM8350_CLOCK_CONTROL_1 0x28 +#define WM8350_CLOCK_CONTROL_2 0x29 +#define WM8350_FLL_CONTROL_1 0x2A +#define WM8350_FLL_CONTROL_2 0x2B +#define WM8350_FLL_CONTROL_3 0x2C +#define WM8350_FLL_CONTROL_4 0x2D +#define WM8350_DAC_CONTROL 0x30 +#define WM8350_DAC_DIGITAL_VOLUME_L 0x32 +#define WM8350_DAC_DIGITAL_VOLUME_R 0x33 +#define WM8350_DAC_LR_RATE 0x35 +#define WM8350_DAC_CLOCK_CONTROL 0x36 +#define WM8350_DAC_MUTE 0x3A +#define WM8350_DAC_MUTE_VOLUME 0x3B +#define WM8350_DAC_SIDE 0x3C +#define WM8350_ADC_CONTROL 0x40 +#define WM8350_ADC_DIGITAL_VOLUME_L 0x42 +#define WM8350_ADC_DIGITAL_VOLUME_R 0x43 +#define WM8350_ADC_DIVIDER 0x44 +#define WM8350_ADC_LR_RATE 0x46 +#define WM8350_INPUT_CONTROL ...
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com> --- include/linux/mfd/wm8350/gpio.h | 326 +++++++++++++++++++++++++++++++++++++++ 1 files changed, 326 insertions(+), 0 deletions(-) create mode 100644 include/linux/mfd/wm8350/gpio.h diff --git a/include/linux/mfd/wm8350/gpio.h b/include/linux/mfd/wm8350/gpio.h new file mode 100644 index 0000000..928aa6e --- /dev/null +++ b/include/linux/mfd/wm8350/gpio.h @@ -0,0 +1,326 @@ +/* + * gpio.h -- GPIO Driver for Wolfson WM8350 PMIC + * + * Copyright 2007 Wolfson Microelectronics PLC + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the + * Free Software Foundation; either version 2 of the License, or (at your + * option) any later version. + * + */ + +#ifndef __LINUX_MFD_WM8350_GPIO_H_ +#define __LINUX_MFD_WM8350_GPIO_H_ + +/* + * GPIO Registers. + */ +#define WM8350_GPIO_DEBOUNCE 0x80 +#define WM8350_GPIO_PIN_PULL_UP_CONTROL 0x81 +#define WM8350_GPIO_PULL_DOWN_CONTROL 0x82 +#define WM8350_GPIO_INT_MODE 0x83 +#define WM8350_GPIO_CONTROL 0x85 +#define WM8350_GPIO_CONFIGURATION_I_O 0x86 +#define WM8350_GPIO_PIN_POLARITY_TYPE 0x87 +#define WM8350_GPIO_FUNCTION_SELECT_1 0x8C +#define WM8350_GPIO_FUNCTION_SELECT_2 0x8D +#define WM8350_GPIO_FUNCTION_SELECT_3 0x8E +#define WM8350_GPIO_FUNCTION_SELECT_4 0x8F + +/* + * GPIO Functions + */ +#define WM8350_GPIO0_GPIO_IN 0x0 +#define WM8350_GPIO0_GPIO_OUT 0x0 +#define WM8350_GPIO0_PWR_ON_IN 0x1 +#define WM8350_GPIO0_PWR_ON_OUT 0x1 +#define WM8350_GPIO0_LDO_EN_IN 0x2 +#define WM8350_GPIO0_VRTC_OUT 0x2 +#define WM8350_GPIO0_LPWR1_IN 0x3 +#define WM8350_GPIO0_POR_B_OUT 0x3 + +#define WM8350_GPIO1_GPIO_IN 0x0 +#define WM8350_GPIO1_GPIO_OUT 0x0 +#define WM8350_GPIO1_PWR_ON_IN 0x1 +#define ...
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com> --- include/linux/mfd/wm8350/pmic.h | 699 +++++++++++++++++++++++++++++++++++++++ 1 files changed, 699 insertions(+), 0 deletions(-) create mode 100644 include/linux/mfd/wm8350/pmic.h diff --git a/include/linux/mfd/wm8350/pmic.h b/include/linux/mfd/wm8350/pmic.h new file mode 100644 index 0000000..28d2fab --- /dev/null +++ b/include/linux/mfd/wm8350/pmic.h @@ -0,0 +1,699 @@ +/* + * pmic.h -- Power Managment Driver for Wolfson WM8350 PMIC + * + * Copyright 2007 Wolfson Microelectronics PLC + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the + * Free Software Foundation; either version 2 of the License, or (at your + * option) any later version. + * + */ + +#ifndef __LINUX_MFD_WM8350_PMIC_H +#define __LINUX_MFD_WM8350_PMIC_H + +/* + * Register values. + */ + +#define WM8350_CURRENT_SINK_DRIVER_A 0xAC +#define WM8350_CSA_FLASH_CONTROL 0xAD +#define WM8350_CURRENT_SINK_DRIVER_B 0xAE +#define WM8350_CSB_FLASH_CONTROL 0xAF +#define WM8350_DCDC_LDO_REQUESTED 0xB0 +#define WM8350_DCDC_ACTIVE_OPTIONS 0xB1 +#define WM8350_DCDC_SLEEP_OPTIONS 0xB2 +#define WM8350_POWER_CHECK_COMPARATOR 0xB3 +#define WM8350_DCDC1_CONTROL 0xB4 +#define WM8350_DCDC1_TIMEOUTS 0xB5 +#define WM8350_DCDC1_LOW_POWER 0xB6 +#define WM8350_DCDC2_CONTROL 0xB7 +#define WM8350_DCDC2_TIMEOUTS 0xB8 +#define WM8350_DCDC3_CONTROL 0xBA +#define WM8350_DCDC3_TIMEOUTS 0xBB +#define WM8350_DCDC3_LOW_POWER 0xBC +#define WM8350_DCDC4_CONTROL 0xBD +#define WM8350_DCDC4_TIMEOUTS 0xBE +#define WM8350_DCDC4_LOW_POWER 0xBF +#define ...
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com> --- include/linux/mfd/wm8350/supply.h | 105 +++++++++++++++++++++++++++++++++++++ 1 files changed, 105 insertions(+), 0 deletions(-) create mode 100644 include/linux/mfd/wm8350/supply.h diff --git a/include/linux/mfd/wm8350/supply.h b/include/linux/mfd/wm8350/supply.h new file mode 100644 index 0000000..f1d4317 --- /dev/null +++ b/include/linux/mfd/wm8350/supply.h @@ -0,0 +1,105 @@ +/* + * supply.h -- Power Supply Driver for Wolfson WM8350 PMIC + * + * Copyright 2007 Wolfson Microelectronics PLC + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the + * Free Software Foundation; either version 2 of the License, or (at your + * option) any later version. + * + */ + +#ifndef __LINUX_MFD_WM8350_SUPPLY_H_ +#define __LINUX_MFD_WM8350_SUPPLY_H_ + +/* + * Charger registers + */ +#define WM8350_BATTERY_CHARGER_CONTROL_1 0xA8 +#define WM8350_BATTERY_CHARGER_CONTROL_2 0xA9 +#define WM8350_BATTERY_CHARGER_CONTROL_3 0xAA + +/* + * R168 (0xA8) - Battery Charger Control 1 + */ +#define WM8350_CHG_ENA_R168 0x8000 +#define WM8350_CHG_THR 0x2000 +#define WM8350_CHG_EOC_SEL_MASK 0x1C00 +#define WM8350_CHG_TRICKLE_TEMP_CHOKE 0x0200 +#define WM8350_CHG_TRICKLE_USB_CHOKE 0x0100 +#define WM8350_CHG_RECOVER_T 0x0080 +#define WM8350_CHG_END_ACT 0x0040 +#define WM8350_CHG_FAST 0x0020 +#define WM8350_CHG_FAST_USB_THROTTLE 0x0010 +#define WM8350_CHG_NTC_MON 0x0008 +#define WM8350_CHG_BATT_HOT_MON 0x0004 +#define WM8350_CHG_BATT_COLD_MON 0x0002 +#define WM8350_CHG_CHIP_TEMP_MON 0x0001 + +/* + * R169 (0xA9) - Battery Charger Control 2 + */ +#define WM8350_CHG_ACTIVE ...
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com> --- include/linux/mfd/wm8350/comparator.h | 167 +++++++++++++++++++++++++++++++++ 1 files changed, 167 insertions(+), 0 deletions(-) create mode 100644 include/linux/mfd/wm8350/comparator.h diff --git a/include/linux/mfd/wm8350/comparator.h b/include/linux/mfd/wm8350/comparator.h new file mode 100644 index 0000000..0537886 --- /dev/null +++ b/include/linux/mfd/wm8350/comparator.h @@ -0,0 +1,167 @@ +/* + * comparator.h -- Comparator Aux ADC for Wolfson WM8350 PMIC + * + * Copyright 2007 Wolfson Microelectronics PLC + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the + * Free Software Foundation; either version 2 of the License, or (at your + * option) any later version. + */ + +#ifndef __LINUX_MFD_WM8350_COMPARATOR_H_ +#define __LINUX_MFD_WM8350_COMPARATOR_H_ + +/* + * Registers + */ + +#define WM8350_DIGITISER_CONTROL_1 0x90 +#define WM8350_DIGITISER_CONTROL_2 0x91 +#define WM8350_AUX1_READBACK 0x98 +#define WM8350_AUX2_READBACK 0x99 +#define WM8350_AUX3_READBACK 0x9A +#define WM8350_AUX4_READBACK 0x9B +#define WM8350_CHIP_TEMP_READBACK 0x9F +#define WM8350_GENERIC_COMPARATOR_CONTROL 0xA3 +#define WM8350_GENERIC_COMPARATOR_1 0xA4 +#define WM8350_GENERIC_COMPARATOR_2 0xA5 +#define WM8350_GENERIC_COMPARATOR_3 0xA6 +#define WM8350_GENERIC_COMPARATOR_4 0xA7 + +/* + * R144 (0x90) - Digitiser Control (1) + */ +#define WM8350_AUXADC_CTC 0x4000 +#define WM8350_AUXADC_POLL 0x2000 +#define WM8350_AUXADC_HIB_MODE 0x1000 +#define WM8350_AUXADC_SEL8 0x0080 +#define WM8350_AUXADC_SEL7 0x0040 +#define WM8350_AUXADC_SEL6 ...
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com> --- include/linux/mfd/wm8350/rtc.h | 260 ++++++++++++++++++++++++++++++++++++++++ 1 files changed, 260 insertions(+), 0 deletions(-) create mode 100644 include/linux/mfd/wm8350/rtc.h diff --git a/include/linux/mfd/wm8350/rtc.h b/include/linux/mfd/wm8350/rtc.h new file mode 100644 index 0000000..cb337ea --- /dev/null +++ b/include/linux/mfd/wm8350/rtc.h @@ -0,0 +1,260 @@ +/* + * rtc.h -- RTC driver for Wolfson WM8350 PMIC + * + * Copyright 2007 Wolfson Microelectronics PLC + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the + * Free Software Foundation; either version 2 of the License, or (at your + * option) any later version. + */ + +#ifndef __LINUX_MFD_WM8350_RTC_H +#define __LINUX_MFD_WM8350_RTC_H + +/* + * Register values. + */ +#define WM8350_RTC_SECONDS_MINUTES 0x10 +#define WM8350_RTC_HOURS_DAY 0x11 +#define WM8350_RTC_DATE_MONTH 0x12 +#define WM8350_RTC_YEAR 0x13 +#define WM8350_ALARM_SECONDS_MINUTES 0x14 +#define WM8350_ALARM_HOURS_DAY 0x15 +#define WM8350_ALARM_DATE_MONTH 0x16 +#define WM8350_RTC_TIME_CONTROL 0x17 + +/* + * R16 (0x10) - RTC Seconds/Minutes + */ +#define WM8350_RTC_MINS_MASK 0x7F00 +#define WM8350_RTC_MINS_SHIFT 8 +#define WM8350_RTC_SECS_MASK 0x007F +#define WM8350_RTC_SECS_SHIFT 0 + +/* + * R17 (0x11) - RTC Hours/Day + */ +#define WM8350_RTC_DAY_MASK 0x0700 +#define WM8350_RTC_DAY_SHIFT 8 +#define WM8350_RTC_HPM_MASK 0x0020 +#define WM8350_RTC_HPM_SHIFT 5 +#define WM8350_RTC_HRS_MASK 0x001F +#define WM8350_RTC_HRS_SHIFT ...
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com> --- include/linux/mfd/wm8350/wdt.h | 22 ++++++++++++++++++++++ 1 files changed, 22 insertions(+), 0 deletions(-) create mode 100644 include/linux/mfd/wm8350/wdt.h diff --git a/include/linux/mfd/wm8350/wdt.h b/include/linux/mfd/wm8350/wdt.h new file mode 100644 index 0000000..72fc9f5 --- /dev/null +++ b/include/linux/mfd/wm8350/wdt.h @@ -0,0 +1,22 @@ +/* + * wdt.h -- Watchdog Driver for Wolfson WM8350 PMIC + * + * Copyright 2007 Wolfson Microelectronics PLC + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the + * Free Software Foundation; either version 2 of the License, or (at your + * option) any later version. + */ + +#ifndef __LINUX_MFD_WM8350_WDT_H_ +#define __LINUX_MFD_WM8350_WDT_H_ + +#define WM8350_WDOG_HIB_MODE 0x0080 +#define WM8350_WDOG_DEBUG 0x0040 +#define WM8350_WDOG_MODE_MASK 0x0030 +#define WM8350_WDOG_TO_MASK 0x0007 + +#define WM8350_IRQ_SYS_WDOG_TO 24 + +#endif -- 1.5.6.5 --
The WM8350 is an integrated audio and power management subsystem intended for use as the primary PMIC in mobile multimedia applications. The WM8350 can be controlled via either I2C or SPI - the control interface is provided by a separate module in order to allow greatest flexibility in configuring the kernel. This driver was originally written by Liam Girdwood and has since been updated to current kernel APIs and split up for submission by me. All the heavy lifting here was done by Liam. Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com> --- drivers/mfd/Kconfig | 19 + drivers/mfd/Makefile | 2 + drivers/mfd/wm8350-core.c | 456 +++++++++++++ drivers/mfd/wm8350-regmap.c | 1347 +++++++++++++++++++++++++++++++++++++++ include/linux/mfd/wm8350/core.h | 585 +++++++++++++++++ 5 files changed, 2409 insertions(+), 0 deletions(-) create mode 100644 drivers/mfd/wm8350-core.c create mode 100644 drivers/mfd/wm8350-regmap.c create mode 100644 include/linux/mfd/wm8350/core.h diff --git a/drivers/mfd/Kconfig b/drivers/mfd/Kconfig index de596e2..c903aa3 100644 --- a/drivers/mfd/Kconfig +++ b/drivers/mfd/Kconfig @@ -86,6 +86,25 @@ config MFD_WM8400 the device, additional drivers must be enabled in order to use the functionality of the device. +config MFD_WM8350 + tristate + +config MFD_WM8350_CONFIG_MODE_0 + bool + depends on MFD_WM8350 + +config MFD_WM8350_CONFIG_MODE_1 + bool + depends on MFD_WM8350 + +config MFD_WM8350_CONFIG_MODE_2 + bool + depends on MFD_WM8350 + +config MFD_WM8350_CONFIG_MODE_3 + bool + depends on MFD_WM8350 + endmenu menu "Multimedia Capabilities Port drivers" diff --git a/drivers/mfd/Makefile b/drivers/mfd/Makefile index 172439d..b0adca0 100644 --- a/drivers/mfd/Makefile +++ b/drivers/mfd/Makefile @@ -13,6 +13,8 @@ obj-$(CONFIG_MFD_TC6387XB) += tc6387xb.o obj-$(CONFIG_MFD_TC6393XB) += tc6393xb.o obj-$(CONFIG_MFD_WM8400) += wm8400-core.o +wm8350-objs := ...
Implement the I2C control interface for the WM8350. This code was originally written by Liam Girdwood and has been updated for submission by Mark Brown. Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com> --- drivers/mfd/Kconfig | 11 ++++ drivers/mfd/Makefile | 1 + drivers/mfd/wm8350-i2c.c | 120 ++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 132 insertions(+), 0 deletions(-) create mode 100644 drivers/mfd/wm8350-i2c.c diff --git a/drivers/mfd/Kconfig b/drivers/mfd/Kconfig index c903aa3..911439a 100644 --- a/drivers/mfd/Kconfig +++ b/drivers/mfd/Kconfig @@ -105,6 +105,17 @@ config MFD_WM8350_CONFIG_MODE_3 bool depends on MFD_WM8350 +config MFD_WM8350_I2C + tristate "Support Wolfson Microelectronics WM8350 with I2C" + select MFD_WM8350 + depends on I2C + help + The WM8350 is an integrated audio and power management + subsystem with watchdog and RTC functionality for embedded + systems. This option enables core support for the WM8350 with + I2C as the control interface. Additional options must be + selected to enable support for the functionality of the chip. + endmenu menu "Multimedia Capabilities Port drivers" diff --git a/drivers/mfd/Makefile b/drivers/mfd/Makefile index b0adca0..746d37b 100644 --- a/drivers/mfd/Makefile +++ b/drivers/mfd/Makefile @@ -15,6 +15,7 @@ obj-$(CONFIG_MFD_TC6393XB) += tc6393xb.o obj-$(CONFIG_MFD_WM8400) += wm8400-core.o wm8350-objs := wm8350-core.o wm8350-regmap.o obj-$(CONFIG_MFD_WM8350) += wm8350.o +obj-$(CONFIG_MFD_WM8350_I2C) += wm8350-i2c.o obj-$(CONFIG_MFD_CORE) += mfd-core.o diff --git a/drivers/mfd/wm8350-i2c.c b/drivers/mfd/wm8350-i2c.c new file mode 100644 index 0000000..2b0569c --- /dev/null +++ b/drivers/mfd/wm8350-i2c.c @@ -0,0 +1,120 @@ +/* + * wm8350-i2c.c -- Generic I2C driver for Wolfson WM8350 PMIC + * + * This driver defines and configures the WM8350 for the Freescale i.MX32ADS. + * + * Copyright 2007, 2008 Wolfson ...
The WM8350 provides a number of user-configurable pins providing access to various signals generated by the functions on the chip. These are referred to as GPIO pins in the device documentation but in Linux terms they are more general than that, providing configuration of alternate functions. This patch implements support for selecting the alternate functions for these pins. They can also be used as GPIOs in the normal Linux sense - a subsequent patch will add support for doing so. This code was all written by Liam Girdwood and has had minor updates and rearrangements by Mark Brown. Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com> --- drivers/mfd/Makefile | 2 +- drivers/mfd/wm8350-gpio.c | 222 +++++++++++++++++++++++++++++++++++++++ include/linux/mfd/wm8350/gpio.h | 10 ++ 3 files changed, 233 insertions(+), 1 deletions(-) create mode 100644 drivers/mfd/wm8350-gpio.c diff --git a/drivers/mfd/Makefile b/drivers/mfd/Makefile index 746d37b..8c0b7f2 100644 --- a/drivers/mfd/Makefile +++ b/drivers/mfd/Makefile @@ -13,7 +13,7 @@ obj-$(CONFIG_MFD_TC6387XB) += tc6387xb.o obj-$(CONFIG_MFD_TC6393XB) += tc6393xb.o obj-$(CONFIG_MFD_WM8400) += wm8400-core.o -wm8350-objs := wm8350-core.o wm8350-regmap.o +wm8350-objs := wm8350-core.o wm8350-regmap.o wm8350-gpio.o obj-$(CONFIG_MFD_WM8350) += wm8350.o obj-$(CONFIG_MFD_WM8350_I2C) += wm8350-i2c.o diff --git a/drivers/mfd/wm8350-gpio.c b/drivers/mfd/wm8350-gpio.c new file mode 100644 index 0000000..ebf99be --- /dev/null +++ b/drivers/mfd/wm8350-gpio.c @@ -0,0 +1,222 @@ +/* + * wm8350-core.c -- Device access for Wolfson WM8350 + * + * Copyright 2007, 2008 Wolfson Microelectronics PLC. + * + * Author: Liam Girdwood + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the + * Free Software Foundation; either version 2 of the License, or (at your + * option) any later ...
Some functions of the WM8350 require board-specific initialisation on
startup. Provide a callback to the WM8350 driver in platform data
for platforms to use to configure the chip. Use of a callback allows
platforms to control the ordering of initialisation which can be
important.
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
---
drivers/mfd/wm8350-core.c | 12 +++++++++++-
drivers/mfd/wm8350-i2c.c | 2 +-
include/linux/mfd/wm8350/core.h | 14 +++++++++++++-
3 files changed, 25 insertions(+), 3 deletions(-)
diff --git a/drivers/mfd/wm8350-core.c b/drivers/mfd/wm8350-core.c
index c7552c0..071834b 100644
--- a/drivers/mfd/wm8350-core.c
+++ b/drivers/mfd/wm8350-core.c
@@ -388,7 +388,8 @@ out:
}
EXPORT_SYMBOL_GPL(wm8350_create_cache);
-int wm8350_device_init(struct wm8350 *wm8350)
+int wm8350_device_init(struct wm8350 *wm8350,
+ struct wm8350_platform_data *pdata)
{
int ret = -EINVAL;
u16 id1, id2, mask, mode;
@@ -439,6 +440,15 @@ int wm8350_device_init(struct wm8350 *wm8350)
return ret;
}
+ if (pdata->init) {
+ ret = pdata->init(wm8350);
+ if (ret != 0) {
+ dev_err(wm8350->dev, "Platform init() failed: %d\n",
+ ret);
+ goto err;
+ }
+ }
+
return 0;
err:
diff --git a/drivers/mfd/wm8350-i2c.c b/drivers/mfd/wm8350-i2c.c
index 2b0569c..245b790 100644
--- a/drivers/mfd/wm8350-i2c.c
+++ b/drivers/mfd/wm8350-i2c.c
@@ -65,7 +65,7 @@ static int wm8350_i2c_probe(struct i2c_client *i2c,
wm8350->read_dev = wm8350_i2c_read_device;
wm8350->write_dev = wm8350_i2c_write_device;
- ret = wm8350_device_init(wm8350);
+ ret = wm8350_device_init(wm8350, i2c->dev.platform_data);
if (ret < 0)
goto err;
diff --git a/include/linux/mfd/wm8350/core.h b/include/linux/mfd/wm8350/core.h
index 94778c1..8f2beae 100644
--- a/include/linux/mfd/wm8350/core.h
+++ b/include/linux/mfd/wm8350/core.h
@@ -564,10 +564,22 @@ struct wm8350 {
u16 *reg_cache;
};
+/**
+ * Data to be supplied by the ...The WM8350 has an interrupt line to the CPU which is shared by the
devices on the CPU. This patch adds support for the interrupt
controller within the WM8350 which identifies which identifies the
interrupt cause. In common with other similar chips this is done
outside the standard interrupt framework due to the need to access
the interrupt controller over an interrupt-driven bus.
This code was all originally written by Liam Girdwood with updates for
submission by me.
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
---
drivers/mfd/wm8350-core.c | 770 ++++++++++++++++++++++++++++++++++++++-
drivers/mfd/wm8350-i2c.c | 2 +-
include/linux/mfd/wm8350/core.h | 21 +-
3 files changed, 787 insertions(+), 6 deletions(-)
diff --git a/drivers/mfd/wm8350-core.c b/drivers/mfd/wm8350-core.c
index 071834b..e74829f 100644
--- a/drivers/mfd/wm8350-core.c
+++ b/drivers/mfd/wm8350-core.c
@@ -15,15 +15,20 @@
#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/init.h>
+#include <linux/bug.h>
#include <linux/device.h>
#include <linux/delay.h>
#include <linux/interrupt.h>
+#include <linux/workqueue.h>
#include <linux/mfd/wm8350/core.h>
#include <linux/mfd/wm8350/audio.h>
+#include <linux/mfd/wm8350/comparator.h>
#include <linux/mfd/wm8350/gpio.h>
#include <linux/mfd/wm8350/pmic.h>
+#include <linux/mfd/wm8350/rtc.h>
#include <linux/mfd/wm8350/supply.h>
+#include <linux/mfd/wm8350/wdt.h>
#define WM8350_UNLOCK_KEY 0x0013
#define WM8350_LOCK_KEY 0x0000
@@ -321,6 +326,743 @@ int wm8350_reg_unlock(struct wm8350 *wm8350)
}
EXPORT_SYMBOL_GPL(wm8350_reg_unlock);
+static void wm8350_irq_call_handler(struct wm8350 *wm8350, int irq)
+{
+ mutex_lock(&wm8350->irq_mutex);
+
+ if (wm8350->irq[irq].handler)
+ wm8350->irq[irq].handler(wm8350, irq, wm8350->irq[irq].data);
+ else {
+ dev_err(wm8350->dev, "irq %d nobody cared. now masked.\n",
+ irq);
+ wm8350_mask_irq(wm8350, ...The WM8350 features six DCDC convertors (four buck and two boost), four
LDO voltage regulators and two constant current sinks. This driver adds
support for these through the regulator API.
This driver was written by Liam Girdwood with updates for submission
from Mark Brown.
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
---
drivers/mfd/wm8350-core.c | 6 +
drivers/regulator/Kconfig | 9 +
drivers/regulator/Makefile | 1 +
drivers/regulator/wm8350-regulator.c | 1431 ++++++++++++++++++++++++++++++++++
include/linux/mfd/wm8350/core.h | 5 +
include/linux/mfd/wm8350/pmic.h | 42 +
6 files changed, 1494 insertions(+), 0 deletions(-)
create mode 100644 drivers/regulator/wm8350-regulator.c
diff --git a/drivers/mfd/wm8350-core.c b/drivers/mfd/wm8350-core.c
index e74829f..9a1a0b2 100644
--- a/drivers/mfd/wm8350-core.c
+++ b/drivers/mfd/wm8350-core.c
@@ -1218,6 +1218,12 @@ EXPORT_SYMBOL_GPL(wm8350_device_init);
void wm8350_device_exit(struct wm8350 *wm8350)
{
+ int i;
+
+ for (i = 0; i < ARRAY_SIZE(wm8350->pmic.pdev); i++)
+ if (wm8350->pmic.pdev[i] != NULL)
+ platform_device_unregister(wm8350->pmic.pdev[i]);
+
free_irq(wm8350->chip_irq, wm8350);
flush_work(&wm8350->irq_work);
kfree(wm8350->reg_cache);
diff --git a/drivers/regulator/Kconfig b/drivers/regulator/Kconfig
index 9990687..a620023 100644
--- a/drivers/regulator/Kconfig
+++ b/drivers/regulator/Kconfig
@@ -56,6 +56,14 @@ config REGULATOR_BQ24022
charging select between 100 mA and 500 mA charging current
limit.
+config REGULATOR_WM8350
+ tristate "Wolfson Microelectroncis WM8350 AudioPlus PMIC"
+ depends on MFD_WM8350
+ select REGULATOR
+ help
+ This driver provides support for the voltage and current regulators
+ of the WM8350 AudioPlus PMIC.
+
config REGULATOR_WM8400
tristate "Wolfson Microelectroncis WM8400 AudioPlus PMIC"
depends on MFD_WM8400
@@ -63,4 +71,5 @@ config REGULATOR_WM8400
...Most of the subdevices for the WM8350 code are registered in the same
fashion so factor out the code to do the initial registration.
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
---
drivers/mfd/wm8350-core.c | 26 ++++++++++++++++++++++++++
1 files changed, 26 insertions(+), 0 deletions(-)
diff --git a/drivers/mfd/wm8350-core.c b/drivers/mfd/wm8350-core.c
index 9a1a0b2..cd1f76e 100644
--- a/drivers/mfd/wm8350-core.c
+++ b/drivers/mfd/wm8350-core.c
@@ -1130,6 +1130,32 @@ out:
}
EXPORT_SYMBOL_GPL(wm8350_create_cache);
+/*
+ * Register a client device. This is non-fatal since there is no need to
+ * fail the entire device init due to a single platform device failing.
+ */
+static void wm8350_client_dev_register(struct wm8350 *wm8350,
+ const char *name,
+ struct platform_device **pdev)
+{
+ int ret;
+
+ *pdev = platform_device_alloc(name, -1);
+ if (pdev == NULL) {
+ dev_err(wm8350->dev, "Failed to allocate %s\n", name);
+ return;
+ }
+
+ (*pdev)->dev.parent = wm8350->dev;
+ platform_set_drvdata(*pdev, wm8350);
+ ret = platform_device_add(*pdev);
+ if (ret != 0) {
+ dev_err(wm8350->dev, "Failed to register %s: %d\n", name, ret);
+ platform_device_put(*pdev);
+ *pdev = NULL;
+ }
+}
+
int wm8350_device_init(struct wm8350 *wm8350, int irq,
struct wm8350_platform_data *pdata)
{
--
1.5.6.5
--
Out of curiosity (and also because I would like to start working on improving mfd-core), why didnt you consider using the mfd-core API ? Cheers, -- Intel Open Source Technology Centre http://oss.intel.com/ --
I did actually consider that - if it hadn't been so near the merge window it'd have got a bit more attention but I'd been going for a minimally invasive approach. Originally the major issue was that the MFD API only worked for platform devices but that has now been resolved. Now the main issue for the WM8350 is that the MFD core API uses platform_device_add_resources() unconditionally but that fails if the device has no resources as will be the case for anything on the WM8350, at least until I integrate the interrupt controller with the standard interrupt interface. The MFD core does ignore the result of the call currently but it probably shouldn't and I didn't want to rely on it continuing to do so. The patch below ought to address that, though it's tested with my "Hey, look! It compiles!" test plan - if it looks sane to you I'll give it a test and repost with a proper changelog. It's not an issue for the WM8350 but some devices with interrupt controllers may have issues since currently the MFD API wants to put all the interrupts within a per-device range but for some devices there will be interrupts exposed via separate IRQ lines (so you don't have to take the hit of working with an I2C/SPI interrupt controller) meaning that some of the interrupts for subdevices may be in different ranges. For the WM8350 this isn't such a problem since everything *can* go via the main interrupt controller and overrides can be provided via platform data (as they are at present, though the main interrupt controller doesn't use the standard API) but if use of a separate interrupt line were non-optional it'd be a problem. There's also the issue of passing over the pointer to the shared device data for arbitration - you can use platform data but the MFD API wants to copy it so it's a bit fiddly. I'm thinking that the sensible thing may just be to have the child devices use the parent link in the device tree for this which is already fine with the MFD core. diff --git ...
I expect it to implement the giolib interface, right ? Cheers, --
Hi Liam, I'm fine with Mark's mfd patches going upstream via your tree. Please add an "Acked-by: Samuel Ortiz <sameo@openedhand.com>" line to all the mfd patches (i.e. all of them except patch #13). Thanks to Mark and you for those. Cheers, -- Intel Open Source Technology Centre http://oss.intel.com/ --
I'm fine with the git URL for now, thanks. Cheers, Samuel. -- Intel Open Source Technology Centre http://oss.intel.com/ --
That would be fine. The intention is to do a pull request later next week. Fwiw, most of the MFD stuff in this series is headers so should be quick. Cheers Liam --
| Greg KH | Og dreams of kernels |
| Jens Axboe | [PATCH 31/33] Fusion: sg chaining support |
| Arnd Bergmann | Re: finding your own dead "CONFIG_" variables |
| Mark Brown | [PATCH 2/2] Subject: natsemi: Allow users to disable workaround for DspCfg reset |
| Tony Breeds |
