tnetv107x ssp drivers
Subsystems (9)
v6 cover tnetv107x ssp drivers
TI's sequencer serial port (TI-SSP) is a jack-of-all-trades type of serial port device. It has a built-in programmable execution engine that can be programmed to operate as almost any serial bus (I2C, SPI, EasyScale, and others).
This patch series implements a driver stack that looks like the following:
+--------+
| eeprom | . . .
+--------+
+-----------+ +--------------+ +---------+
| regulator | . . . | i2c-gpio | | 1-wire | . . .
+-----------+ +--------------+ +---------+
+----------------------+ +--------------------------------+
| ssp-spi | | ssp-gpio |
+----------------------+ +--------------------------------+
+----------------------------------------------------------+
| ssp |
+----------------------------------------------------------+Changes between v6 and v5 of this series:
- Changed initcalls to module_init() across all drivers. This series now uses a late_initcall() in the board to delay initialization of gpio and regulator dependent devices.
Changes between v5 and v4 of this series:
- Moved drivers from misc/gpio/spi to mfd
- Removed implicit init-time iosel setup
- Minor cleanups in backlight driver
Changes between v3 and v4 of this series:
- Replaced polled wait for sequence termination with interrupt
- Improved locking within SSP driver
- Other minor cleanups
Changes between v2 and v3 of this series:
- Minor cleanups in Kconfig and Makefile ordering
Changes between v1 and v2 of this series:
- Replaced open()/close() semantics with dynamic platform_device registration on SSP probe.
- Removed user-land interface to regulator registers
- More sensible regulator constraints
- Other minor cleanups
Cyril Chemparathy (12):
misc: add driver for sequencer serial port
davinci: add tnetv107x ssp platform device
davinci: add ssp config for tnetv107x evm board
spi: add ti-ssp spi master driver
davinci: add spi devices on tnetv107x evm
regulator: add driver for tps6524x regulator
davinci: add tnetv107x evm regulators
gpio: add ti-ssp gpio driver
davinci: add tnetv107x evm ti-ssp gpio device
backlight: add support for tps6116x controller
davinci: add tnetv107x evm backlight device
davinci: add tnetv107x evm i2c eeprom device
arch/arm/mach-davinci/board-tnetv107x-evm.c | 197 +++++++ arch/arm/mach-davinci/devices-tnetv107x.c | 25 + arch/arm/mach-davinci/include/mach/tnetv107x.h | 2 + arch/arm/mach-davinci/tnetv107x.c | 2 +- drivers/gpio/Kconfig | 10 + drivers/gpio/Makefile | 1 + drivers/gpio/ti-ssp-gpio.c | 206 +++++++ drivers/mfd/Kconfig | 11 + drivers/mfd/Makefile | 1 + drivers/mfd/ti-ssp.c | 472 ++++++++++++++++ drivers/regulator/Kconfig | 10 + drivers/regulator/Makefile | 1 + drivers/regulator/tps6524x-regulator.c | 692 ++++++++++++++++++++++++ drivers/spi/Kconfig | 10 + drivers/spi/Makefile | 1 + drivers/spi/ti-ssp-spi.c | 402 ++++++++++++++ drivers/video/backlight/Kconfig | 7 + drivers/video/backlight/Makefile | 2 +- drivers/video/backlight/tps6116x.c | 298 ++++++++++ include/linux/mfd/ti_ssp.h | 97 ++++ 20 files changed, 2445 insertions(+), 2 deletions(-) create mode 100644 drivers/gpio/ti-ssp-gpio.c create mode 100644 drivers/mfd/ti-ssp.c create mode 100644 drivers/regulator/tps6524x-regulator.c create mode 100644 drivers/spi/ti-ssp-spi.c create mode 100644 drivers/video/backlight/tps6116x.c create mode 100644 include/linux/mfd/ti_ssp.h
PATCH v6 1/12 misc: add driver for sequencer serial port
TI's sequencer serial port (TI-SSP) is a jack-of-all-trades type of serial port device. It has a built-in programmable execution engine that can be programmed to operate as almost any serial bus (I2C, SPI, EasyScale, and others).
This patch adds a driver for this controller device. The driver does not expose a user-land interface. Protocol drivers built on top of this layer are expected to remain in-kernel.
--- drivers/mfd/Kconfig | 11 + drivers/mfd/Makefile | 1 + drivers/mfd/ti-ssp.c | 472 ++++++++++++++++++++++++++++++++++++++++++++ include/linux/mfd/ti_ssp.h | 87 ++++++++ 4 files changed, 571 insertions(+), 0 deletions(-) create mode 100644 drivers/mfd/ti-ssp.c create mode 100644 include/linux/mfd/ti_ssp.h
drivers/mfd/Kconfig +11 -0
@@ -81,6 +81,17 @@ config MFD_DM355EVM_MSP boards. MSP430 firmware manages resets and power sequencing, inputs from buttons and the IR remote, LEDs, an RTC, and more. +config MFD_TI_SSP + tristate "TI Sequencer Serial Port support" + depends on ARCH_DAVINCI_TNETV107X + select MFD_CORE + ---help--- + Say Y here if you want support for the Sequencer Serial Port + in a Texas Instruments TNETV107X SoC. + + To compile this driver as a module, choose M here: the + module will be called ti-ssp. + config HTC_EGPIO bool "HTC EGPIO support" depends on GENERIC_HARDIRQS && GPIOLIB && ARM
drivers/mfd/Makefile +1 -0
@@ -14,6 +14,7 @@ obj-$(CONFIG_HTC_I2CPLD) += htc-i2cpld.o obj-$(CONFIG_MFD_DAVINCI_VOICECODEC) += davinci_voicecodec.o obj-$(CONFIG_MFD_DM355EVM_MSP) += dm355evm_msp.o +obj-$(CONFIG_MFD_TI_SSP) += ti-ssp.o obj-$(CONFIG_MFD_STMPE) += stmpe.o obj-$(CONFIG_MFD_TC35892) += tc35892.o
drivers/mfd/ti-ssp.c new file +472 -0
472 lines not on this page · raw message
include/linux/mfd/ti_ssp.h new file +87 -0
87 lines not on this page · raw message
Signature · 1 line
1.7.1
PATCH v6 2/12 davinci: add tnetv107x ssp platform device
In reply to Cyril ChemparathyThis patch adds an SSP platform device definition for the tnetv107x soc family. The clock lookup entry has also been updated to match.
--- arch/arm/mach-davinci/devices-tnetv107x.c | 25 ++++++++++++++++++++++++ arch/arm/mach-davinci/include/mach/tnetv107x.h | 2 + arch/arm/mach-davinci/tnetv107x.c | 2 +- 3 files changed, 28 insertions(+), 1 deletions(-)
arch/arm/mach-davinci/devices-tnetv107x.c +25 -0
@@ -35,6 +35,7 @@#define TNETV107X_SDIO0_BASE 0x08088700#define TNETV107X_SDIO1_BASE 0x08088800#define TNETV107X_KEYPAD_BASE 0x08088a00 +#define TNETV107X_SSP_BASE 0x08088c00#define TNETV107X_ASYNC_EMIF_CNTRL_BASE 0x08200000#define TNETV107X_ASYNC_EMIF_DATA_CE0_BASE 0x30000000#define TNETV107X_ASYNC_EMIF_DATA_CE1_BASE 0x40000000
@@ -342,6 +343,25 @@ static struct platform_device tsc_device = { .resource = tsc_resources, }; +static struct resource ssp_resources[] = { + { + .start =TNETV107X_SSP_BASE , + .end =TNETV107X_SSP_BASE +0x1ff , + .flags =IORESOURCE_MEM , + }, + { + .start =IRQ_TNETV107X_SSP , + .flags =IORESOURCE_IRQ , + }, +}; + +static struct platform_device ssp_device = { + .name ="ti-ssp" , + .id =-1 , + .num_resources =ARRAY_SIZE (ssp_resources), + .resource = ssp_resources, +}; +void __init tnetv107x_devices_init (struct tnetv107x_device_info *info) {int i, error;
@@ -380,4 +400,9 @@ void __init tnetv107x_devices_init(struct tnetv107x_device_info *info) keypad_device.dev.platform_data = info->keypad_config;platform_device_register (&keypad_device); } + +if (info->ssp_config) { + ssp_device.dev.platform_data = info->ssp_config; +platform_device_register (&ssp_device); + } }
arch/arm/mach-davinci/include/mach/tnetv107x.h +2 -0
@@ -34,6 +34,7 @@#include <linux/serial_8250.h> #include <linux/input/matrix_keypad.h> +#include <linux/mfd/ti_ssp.h> #include <mach/mmc.h> #include <mach/nand.h>
@@ -44,6 +45,7 @@ struct tnetv107x_device_info {struct davinci_mmc_config *mmc_config[2 ];/* 2 controllers */ struct davinci_nand_pdata *nand_config[4 ];/* 4 chipsels */ struct matrix_keypad_platform_data *keypad_config; +struct ti_ssp_data *ssp_config; };extern struct platform_device tnetv107x_wdt_device;
arch/arm/mach-davinci/tnetv107x.c +1 -1
@@ -278,7 +278,7 @@ static struct clk_lookup clks[] = {CLK (NULL ,"timer1" , &clk_timer1),CLK ("tnetv107x_wdt.0" ,NULL , &clk_wdt_arm),CLK (NULL ,"clk_wdt_dsp" , &clk_wdt_dsp), -CLK ("ti-ssp.0" ,NULL , &clk_ssp), +CLK ("ti-ssp" ,NULL , &clk_ssp),CLK (NULL ,"clk_tdm0" , &clk_tdm0),CLK (NULL ,"clk_vlynq" , &clk_vlynq), CLK(NULL, "clk_mcdma", &clk_mcdma),
Signature · 1 line
1.7.1
PATCH v6 3/12 davinci: add ssp config for tnetv107x evm board
In reply to Cyril ChemparathyThis patch adds SSP configuration and pin muxing info for tnetv107x evm boards.
--- arch/arm/mach-davinci/board-tnetv107x-evm.c | 14 ++++++++++++++ 1 files changed, 14 insertions(+), 0 deletions(-)
arch/arm/mach-davinci/board-tnetv107x-evm.c +14 -0
@@ -99,6 +99,12 @@ static const short uart1_pins[] __initdata = {-1 }; +static const short ssp_pins[]__initdata = { +TNETV107X_SSP0_0 ,TNETV107X_SSP0_1 ,TNETV107X_SSP0_2 , +TNETV107X_SSP1_0 ,TNETV107X_SSP1_1 ,TNETV107X_SSP1_2 , +TNETV107X_SSP1_3 ,-1 +}; +static struct mtd_partition nand_partitions[] = {/* bootloader (U-Boot, etc) in first 12 sectors */ {
@@ -196,17 +202,25 @@ static struct matrix_keypad_platform_data keypad_config = { .no_autorepeat = 0, }; +static struct ti_ssp_data ssp_config = { + .out_clock =250 *1000 , + .dev_data = { + }, +}; +static struct tnetv107x_device_info evm_device_info__initconst = { .serial_config = &serial_config, .mmc_config[1 ] = &mmc_config,/* controller 1 */ .nand_config[0 ] = &nand_config,/* chip select 0 */ .keypad_config = &keypad_config, + .ssp_config = &ssp_config, };static __init void tnetv107x_evm_board_init (void ) {davinci_cfg_reg_list (sdio1_pins);davinci_cfg_reg_list (uart1_pins); +davinci_cfg_reg_list (ssp_pins);tnetv107x_devices_init (&evm_device_info); }
Signature · 1 line
1.7.1
PATCH v6 4/12 spi: add ti-ssp spi master driver
In reply to Cyril ChemparathyThis patch adds an SPI master implementation that operates on top of an underlying TI-SSP port.
--- drivers/spi/Kconfig | 10 + drivers/spi/Makefile | 1 + drivers/spi/ti-ssp-spi.c | 402 ++++++++++++++++++++++++++++++++++++++++++++ include/linux/mfd/ti_ssp.h | 6 + 4 files changed, 419 insertions(+), 0 deletions(-) create mode 100644 drivers/spi/ti-ssp-spi.c
drivers/spi/Kconfig +10 -0
@@ -336,6 +336,16 @@ config SPI_TEGRA help SPI driver for NVidia Tegra SoCs +config SPI_TI_SSP + tristate "TI Sequencer Serial Port - SPI Support" + depends on MFD_TI_SSP + help + This selects an SPI master implementation using a TI sequencer + serial port. + + To compile this driver as a module, choose M here: the + module will be called ti-ssp-spi. + config SPI_TOPCLIFF_PCH tristate "Topcliff PCH SPI Controller" depends on PCI
drivers/spi/Makefile +1 -0
@@ -40,6 +40,7 @@ obj-$(CONFIG_SPI_S3C24XX_GPIO) += spi_s3c24xx_gpio.o obj-$(CONFIG_SPI_S3C24XX) += spi_s3c24xx_hw.o obj-$(CONFIG_SPI_S3C64XX) += spi_s3c64xx.o obj-$(CONFIG_SPI_TEGRA) += spi_tegra.o +obj-$(CONFIG_SPI_TI_SSP) += ti-ssp-spi.o obj-$(CONFIG_SPI_TOPCLIFF_PCH) += spi_topcliff_pch.o obj-$(CONFIG_SPI_TXX9) += spi_txx9.o obj-$(CONFIG_SPI_XILINX) += xilinx_spi.o
drivers/spi/ti-ssp-spi.c new file +402 -0
402 lines not on this page · raw message
include/linux/mfd/ti_ssp.h +6 -0
@@ -32,6 +32,12 @@ struct ti_ssp_data {struct ti_ssp_dev_data dev_data[2 ]; }; +struct ti_ssp_spi_data { +unsigned long iosel; +int num_cs; +void (*select)(int cs); +}; +/* * Sequencer port IO pin configuration bits. These do not correlate 1-1 with * the hardware. The iosel field in the port data combines iosel1 and iosel2,
Signature · 1 line
1.7.1
PATCH v6 5/12 davinci: add spi devices on tnetv107x evm
In reply to Cyril ChemparathyThis patch adds definitions for spi devices on the tnetv107x evm platform.
--- arch/arm/mach-davinci/board-tnetv107x-evm.c | 43 +++++++++++++++++++++++++++ 1 files changed, 43 insertions(+), 0 deletions(-)
arch/arm/mach-davinci/board-tnetv107x-evm.c +43 -0
@@ -25,6 +25,7 @@#include <linux/mtd/partitions.h> #include <linux/input.h> #include <linux/input/matrix_keypad.h> +#include <linux/spi/spi.h> #include <asm/mach/arch.h> #include <asm/mach-types.h>
@@ -37,6 +38,7 @@#define EVM_MMC_WP_GPIO 21#define EVM_MMC_CD_GPIO 24 +#define EVM_SPI_CS_GPIO 54static int initialize_gpio (int gpio,char *desc) {
@@ -202,9 +204,45 @@ static struct matrix_keypad_platform_data keypad_config = { .no_autorepeat = 0, }; +static void spi_select_device (int cs) +{ +static int gpio; + +if (!gpio) { +int ret; + ret =gpio_request (EVM_SPI_CS_GPIO ,"spi chipsel" ); +if (ret <0 ) { +pr_err ("cannot open spi chipsel gpio\n" ); + gpio = -ENOSYS ; +return ; + }else { + gpio =EVM_SPI_CS_GPIO ; +gpio_direction_output (gpio,0 ); + } + } + +if (gpio <0 ) +return ; + +return gpio_set_value (gpio, cs ?1 :0 ); +} + +static struct ti_ssp_spi_data spi_master_data = { + .num_cs =2 , + .select = spi_select_device, + .iosel =SSP_PIN_SEL (0 ,SSP_CLOCK ) |SSP_PIN_SEL (1 ,SSP_DATA ) | +SSP_PIN_SEL (2 ,SSP_CHIPSEL ) |SSP_PIN_SEL (3 ,SSP_IN ) | +SSP_INPUT_SEL (3 ), +}; +static struct ti_ssp_data ssp_config = { .out_clock =250 *1000 , .dev_data = { + [1 ] = { + .dev_name ="ti-ssp-spi" , + .pdata = &spi_master_data, + .pdata_size =sizeof (spi_master_data), + }, }, };
@@ -216,6 +254,9 @@ static struct tnetv107x_device_info evm_device_info __initconst = { .ssp_config = &ssp_config, }; +static struct spi_board_info spi_info[]__initconst = { +}; +static __init void tnetv107x_evm_board_init (void ) {davinci_cfg_reg_list (sdio1_pins);
@@ -223,6 +264,8 @@ static __init void tnetv107x_evm_board_init(void)davinci_cfg_reg_list (ssp_pins);tnetv107x_devices_init (&evm_device_info); + +spi_register_board_info (spi_info,ARRAY_SIZE (spi_info)); }#ifdef CONFIG_SERIAL_8250_CONSOLE
Signature · 1 line
1.7.1
PATCH v6 5/12 davinci: add spi devices on tnetv107x evm
Hello.
Quoted 11 lines · Cyril Chemparathy
This patch adds definitions for spi devices on the tnetv107x evm platform.
Signed-off-by Cyril Chemparathy <[email protected]>--- arch/arm/mach-davinci/board-tnetv107x-evm.c | 43 +++++++++++++++++++++++++++ 1 files changed, 43 insertions(+), 0 deletions(-)arch/arm/mach-davinci/board-tnetv107x-evm.c +0
-0
[...]
arch/arm/mach-davinci/board-tnetv107x-evm.c static struct matrix_keypad_platform_data keypad_config = { · line 213
Quoted 11 lines
arch/arm/mach-davinci/board-tnetv107x-evm.c +7
-0@@ -202,9 +204,45 @@ static struct matrix_keypad_platform_data keypad_config = { .no_autorepeat = 0, }; +static void spi_select_device (int cs) +{ +static int gpio; + +if (!gpio) { +int ret; + ret =gpio_request (EVM_SPI_CS_GPIO ,"spi chipsel" );
Why not just:
int ret = gpio_request(EVM_SPI_CS_GPIO, "spi chipsel");
Also, and empty line after declaration wouldn't hurt.
Quoted 4 lines
arch/arm/mach-davinci/board-tnetv107x-evm.c +4
-0+if (ret <0 ) { +pr_err ("cannot open spi chipsel gpio\n" ); + gpio = -ENOSYS ; +return ;
arch/arm/mach-davinci/board-tnetv107x-evm.c static struct matrix_keypad_platform_data keypad_config = { · line 227
Quoted 10 lines
arch/arm/mach-davinci/board-tnetv107x-evm.c +10
-0+ }else { + gpio =EVM_SPI_CS_GPIO ; +gpio_direction_output (gpio,0 ); + } + } + +if (gpio <0 ) +return ; + +return gpio_set_value (gpio, cs ?1 :0 );
Why not do it right with gpio_direction_output() call?
WBR, Sergei
PATCH v6 5/12 davinci: add spi devices on tnetv107x evm
On 11/19/2010 11:25 AM, Sergei Shtylyov wrote:
[...]
Quoted 8 lines
arch/arm/mach-davinci/board-tnetv107x-evm.c static struct matrix_keypad_platform_data keypad_config = { · line 213
Quoted 1 line
arch/arm/mach-davinci/board-tnetv107x-evm.c +1
-0+ ret =gpio_request (EVM_SPI_CS_GPIO ,"spi chipsel" );Why not just:
int ret =
gpio_request(EVM_SPI_CS_GPIO, "spi chipsel");Also, and empty line after declaration wouldn't hurt.
[...]
Quoted 3 lines
arch/arm/mach-davinci/board-tnetv107x-evm.c static struct matrix_keypad_platform_data keypad_config = { · line 227
Quoted 1 line
arch/arm/mach-davinci/board-tnetv107x-evm.c +1
-0+return gpio_set_value (gpio, cs ?1 :0 );Why not do it right with
gpio_direction_output()call?
Sure. I might as well change to use gpio_request_one() while I'm at it.
If I get enough comments to warrant another revision of this series, I will put in this change at the time. Otherwise, I'd rather roll this in with other patches on my pending list. Is that ok?
Thanks for taking a look, Sergei.
Regards
- Cyril.
PATCH v6 6/12 regulator: add driver for tps6524x regulator
In reply to Cyril ChemparathyTPS6524X provides three step-down converters and two general-purpose LDO voltage regulators. This device is interfaced using SPI.
--- drivers/regulator/Kconfig | 10 + drivers/regulator/Makefile | 1 + drivers/regulator/tps6524x-regulator.c | 692 ++++++++++++++++++++++++++++++++ 3 files changed, 703 insertions(+), 0 deletions(-) create mode 100644 drivers/regulator/tps6524x-regulator.c
drivers/regulator/Kconfig +10 -0
@@ -250,5 +250,15 @@ config REGULATOR_TPS6586X help This driver supports TPS6586X voltage regulator chips. +config REGULATOR_TPS6524X + tristate "TI TPS6524X Power regulators" + depends on SPI + help + This driver supports TPS6524X voltage regulator chips. TPS6524X + provides three step-down converters and two general-purpose LDO + voltage regulators. This device is interfaced using a customized + serial interface currently supported on the sequencer serial + port controller. + endif
drivers/regulator/Makefile +1 -0
@@ -34,6 +34,7 @@ obj-$(CONFIG_REGULATOR_AB3100) += ab3100.o obj-$(CONFIG_REGULATOR_TPS65023) += tps65023-regulator.o obj-$(CONFIG_REGULATOR_TPS6507X) += tps6507x-regulator.o +obj-$(CONFIG_REGULATOR_TPS6524X) += tps6524x-regulator.o obj-$(CONFIG_REGULATOR_88PM8607) += 88pm8607.o obj-$(CONFIG_REGULATOR_ISL6271A) += isl6271a-regulator.o obj-$(CONFIG_REGULATOR_AB8500) += ab8500.o
drivers/regulator/tps6524x-regulator.c new file +692 -0
692 lines not on this page · raw message
Signature · 1 line
1.7.1
PATCH v6 7/12 davinci: add tnetv107x evm regulators
In reply to Cyril ChemparathyThis patch adds regulator and spi board info definitions for the tps6524x power management IC found on tnetv107x evm boards.
--- arch/arm/mach-davinci/board-tnetv107x-evm.c | 85 +++++++++++++++++++++++++++ 1 files changed, 85 insertions(+), 0 deletions(-)
arch/arm/mach-davinci/board-tnetv107x-evm.c +85 -0
@@ -26,6 +26,9 @@#include <linux/input.h> #include <linux/input/matrix_keypad.h> #include <linux/spi/spi.h> +#include <linux/regulator/machine.h> +#include <linux/regulator/consumer.h> +#include <linux/regulator/driver.h> #include <asm/mach/arch.h> #include <asm/mach-types.h>
@@ -254,7 +257,89 @@ static struct tnetv107x_device_info evm_device_info __initconst = { .ssp_config = &ssp_config, }; +static struct regulator_consumer_supply usb_consumers[] = { +REGULATOR_SUPPLY ("vbus" ,"musb_hdrc.1" ), +}; + +static struct regulator_consumer_supply lcd_consumers[] = { +REGULATOR_SUPPLY ("vlcd" ,"tps6116x" ), +}; + +static struct regulator_init_data regulators[] = { + { + .constraints = { + .name ="DCDC1" , + .min_uV =1000000 , + .max_uV =1000000 , + .always_on =1 , + .boot_on =1 , + }, + }, + { + .constraints = { + .name ="DCDC2" , + .min_uV =1800000 , + .max_uV =1800000 , + .always_on =1 , + .boot_on =1 , + }, + }, + { + .constraints = { + .name ="DCDC3" , + .min_uV =3300000 , + .max_uV =3300000 , + .always_on =1 , + .boot_on =1 , + }, + }, + { + .constraints = { + .name ="LDO1" , + .min_uV =4800000 , + .max_uV =4800000 , + .always_on =1 , + .boot_on =1 , + }, + }, + { + .constraints = { + .name ="LDO1" , + .min_uV =3300000 , + .max_uV =3300000 , + .always_on =1 , + .boot_on =1 , + }, + }, + { + .num_consumer_supplies =ARRAY_SIZE (usb_consumers), + .consumer_supplies = usb_consumers, + .constraints = { + .name ="USB" , + .min_uA =200000 , + .max_uA =1000000 , + .valid_ops_mask =REGULATOR_CHANGE_CURRENT | +REGULATOR_CHANGE_STATUS , + }, + }, + { + .num_consumer_supplies =ARRAY_SIZE (lcd_consumers), + .consumer_supplies = lcd_consumers, + .constraints = { + .name ="LCD" , + .valid_ops_mask =REGULATOR_CHANGE_STATUS , + }, + }, +}; +static struct spi_board_info spi_info[]__initconst = { + { + .modalias ="tps6524x" , + .bus_num =1 , + .chip_select =0 , + .mode =SPI_MODE_0 , + .platform_data = regulators, + }, };static __init void tnetv107x_evm_board_init (void )
Signature · 1 line
1.7.1
PATCH v6 8/12 gpio: add ti-ssp gpio driver
In reply to Cyril ChemparathyTI's SSP controller pins can be directly read and written to behave like a GPIO. This patch adds a GPIO driver that exposes such functionality.
--- drivers/gpio/Kconfig | 10 ++ drivers/gpio/Makefile | 1 + drivers/gpio/ti-ssp-gpio.c | 206 ++++++++++++++++++++++++++++++++++++++++++++ include/linux/mfd/ti_ssp.h | 4 + 4 files changed, 221 insertions(+), 0 deletions(-) create mode 100644 drivers/gpio/ti-ssp-gpio.c
drivers/gpio/Kconfig +10 -0
@@ -128,6 +128,16 @@ config GPIO_VX855 additional drivers must be enabled in order to use the functionality of the device. +config GPIO_TI_SSP + tristate "TI Sequencer Serial Port - GPIO Support" + depends on MFD_TI_SSP + help + Say yes here to support a GPIO interface on TI SSP port pins. + Each SSP port translates into 4 GPIOs. + + This driver can also be built as a module. If so, the module + will be called ti-ssp-gpio. + comment "I2C GPIO expanders:" config GPIO_MAX7300
drivers/gpio/Makefile +1 -0
@@ -26,6 +26,7 @@ obj-$(CONFIG_GPIO_PL061) += pl061.o obj-$(CONFIG_GPIO_STMPE) += stmpe-gpio.o obj-$(CONFIG_GPIO_TC35892) += tc35892-gpio.o obj-$(CONFIG_GPIO_TIMBERDALE) += timbgpio.o +obj-$(CONFIG_GPIO_TI_SSP) += ti-ssp-gpio.o obj-$(CONFIG_GPIO_TWL4030) += twl4030-gpio.o obj-$(CONFIG_GPIO_UCB1400) += ucb1400_gpio.o obj-$(CONFIG_GPIO_XILINX) += xilinx_gpio.o
drivers/gpio/ti-ssp-gpio.c new file +206 -0
206 lines not on this page · raw message
include/linux/mfd/ti_ssp.h +4 -0
@@ -38,6 +38,10 @@ struct ti_ssp_spi_data {void (*select)(int cs); }; +struct ti_ssp_gpio_data { +int start; +}; +/* * Sequencer port IO pin configuration bits. These do not correlate 1-1 with * the hardware. The iosel field in the port data combines iosel1 and iosel2,
Signature · 1 line
1.7.1
PATCH v6 8/12 gpio: add ti-ssp gpio driver
Quoted 25 lines · Cyril Chemparathy
TI's SSP controller pins can be directly read and written to behave like a GPIO. This patch adds a GPIO driver that exposes such functionality.
Signed-off-by Cyril Chemparathy <[email protected]>---
drivers/gpio/ti-ssp-gpio.c new file +19
-0+static int __devinit ti_ssp_gpio_probe (struct platform_device *pdev) +{ +const struct ti_ssp_gpio_data *pdata = pdev->dev.platform_data; +struct device *dev = &pdev->dev; +struct ti_ssp_gpio_chip *gpio; +int error; + +if (!pdata) { +dev_err (dev,"platform data not found\n" ); +return -EINVAL ; + } + + gpio =kzalloc (sizeof (*gpio),GFP_KERNEL ); +if (!gpio) { +dev_err (dev,"cannot allocate driver data\n" ); +return -ENOMEM ; + } + + gpio->dev = dev;
drivers/gpio/ti-ssp-gpio.c line 144
Quoted 10 lines
drivers/gpio/ti-ssp-gpio.c new file +10
-0+ gpio->iosel =SSP_PIN_SEL (0 ,SSP_IN ) |SSP_PIN_SEL (1 ,SSP_IN ) | +SSP_PIN_SEL (2 ,SSP_IN ) |SSP_PIN_SEL (3 ,SSP_IN ); + error =ti_ssp_set_iosel (gpio->dev, gpio->iosel); +if (error <0 ) { +dev_err (dev,"gpio io setup failed (%d)\n" , error); + goto error; + } + +spin_lock_init (&gpio->lock); +platform_set_drvdata (pdev, gpio);
This looks wrong. gpio is of type ti_ssp_gpio_chip, but the ssp core functions, ssp_read, etc, use dev_to_ssp:
static inline struct ti_ssp *dev_to_ssp(struct device *dev)
{
return dev_get_drvdata(dev->parent);
}If I understand correctly, the ssp core can only be used to for one peripheral at a time. Currently the code will allow you to install several peripherals at once, which will lead to odd behaviour at runtime. Maybe a better approach would be to have something like this in drivers/mfd/ti-ssp.c:
struct ti_ssp {
struct resource *res;
struct device *dev;
void __iomem *regs;
struct clk *clk;
int irq;
wait_queue_head_t wqh;
int in_use;
};static struct ti_ssp ti_ssp = {
.in_use = 0,
};static DEFINE_SPINLOCK(ti_ssp_lock);
struct ti_ssp *ti_ssp_get(void)
{
spin_lock(&ti_ssp_lock);
if (ti_ssp.in_use) {
spin_unlock(&ti_ssp_lock);
return NULL;
}
ti_ssp.in_use = 1;
spin_unlock(&ti_ssp_lock);
return &ti_ssp;
}int ti_ssp_put(void)
{
spin_lock(&ti_ssp_lock);
if (!ti_ssp.in_use) {
spin_unlock(&ti_ssp_lock);
return -ENODEV;
}
ti_ssp.in_use = 0;
spin_unlock(&ti_ssp_lock);
return 0;
}This way, the ssp core api functions can take struct ti_ssp * as their first argument (which can still be an opaque pointer) and the code protects against multiple peripherals attempting to register the ssp core.
~Ryan
Signature · 7 lines
Bluewater Systems Ltd - ARM Technology Solution Centre Ryan Mallon 5 Amuri Park, 404 Barbadoes St ryan at bluewatersys.com PO Box 13 889, Christchurch 8013 http://www.bluewatersys.com New Zealand Phone: +64 3 3779127 Freecall: Australia 1800 148 751 Fax: +64 3 3779135 USA 1800 261 2934
PATCH v6 8/12 gpio: add ti-ssp gpio driver
Quoted 31 lines · Ryan Mallon
Quoted 30 lines · Cyril Chemparathy
TI's SSP controller pins can be directly read and written to behave like a GPIO. ?This patch adds a GPIO driver that exposes such functionality.
Signed-off-by Cyril Chemparathy <[email protected]>---
(quoted diff) +24
-0+static int __devinit ti_ssp_gpio_probe(struct platform_device *pdev) +{ + ? ? const struct ti_ssp_gpio_data *pdata = pdev->dev.platform_data; + ? ? struct device *dev = &pdev->dev; + ? ? struct ti_ssp_gpio_chip *gpio; + ? ? int error; + + ? ? if (!pdata) { + ? ? ? ? ? ? dev_err(dev, "platform data not found\n"); + ? ? ? ? ? ? return -EINVAL; + ? ? } + + ? ? gpio = kzalloc(sizeof(*gpio), GFP_KERNEL); + ? ? if (!gpio) { + ? ? ? ? ? ? dev_err(dev, "cannot allocate driver data\n"); + ? ? ? ? ? ? return -ENOMEM; + ? ? } + + ? ? gpio->dev = dev; + ? ? gpio->iosel = SSP_PIN_SEL(0, SSP_IN) | SSP_PIN_SEL(1, SSP_IN) | + ? ? ? ? ? ? ? ? ? SSP_PIN_SEL(2, SSP_IN) | SSP_PIN_SEL(3, SSP_IN); + ? ? error = ti_ssp_set_iosel(gpio->dev, gpio->iosel); + ? ? if (error < 0) { + ? ? ? ? ? ? dev_err(dev, "gpio io setup failed (%d)\n", error);
Quoted 8 lines
Quoted 5 lines
+ ? ? ? ? ? ? goto error;
+ ? ? }
+
+ ? ?spin_lock_init(&gpio->lock);
+ ? ?platform_set_drvdata(pdev, gpio);This looks wrong. gpio is of type
ti_ssp_gpio_chip, but the ssp core functions,ssp_read, etc, usedev_to_ssp:
This sets the child device's private data pointer, not the parents. dev_to_ssp still correctly returns the parent device private data.
Quoted 8 lines
static inline struct
ti_ssp*dev_to_ssp(struct device *dev) {
? ? ? ?returndev_get_drvdata(dev->parent);
}If I understand correctly, the ssp core can only be used to for one peripheral at a time.
I believe the ssp has 2 channels; thus up to 2 child devices.
Quoted 4 lines
Currently the code will allow you to install
several peripherals at once, which will lead to odd behaviour at runtime. Maybe a better approach would be to have something like this indrivers/mfd/ti-ssp.c:
Only the ssp core itself is allowed to register the peripheral devices, and so using the parent pointer is perfectly valid. I think Cyril's approach is fine.
g.
PATCH v6 8/12 gpio: add ti-ssp gpio driver
Quoted 10 lines · Grant Likely
Quoted 4 lines · Ryan Mallon
Currently the code will allow you to install
several peripherals at once, which will lead to odd behaviour at runtime. Maybe a better approach would be to have something like this indrivers/mfd/ti-ssp.c:Only the ssp core itself is allowed to register the peripheral devices, and so using the parent pointer is perfectly valid. I think Cyril's approach is fine.
This is very much a standard idiom for MFD children in Linux - if the children are entirely reliant on working through a parent-specific API anyway there's no issue with making the parent device be part of that API.
PATCH v6 8/12 gpio: add ti-ssp gpio driver
Quoted 8 lines · Mark Brown
Quoted 6 lines · Grant Likely
Quoted 4 lines · Ryan Mallon
Currently the code will allow you to install
several peripherals at once, which will lead to odd behaviour at runtime. Maybe a better approach would be to have something like this indrivers/mfd/ti-ssp.c:
Quoted 8 lines
Quoted 3 lines
Only the ssp core itself is allowed to register the peripheral devices, and so using the parent pointer is perfectly valid. I think Cyril's approach is fine.
This is very much a standard idiom for MFD children in Linux - if the children are entirely reliant on working through a parent-specific API anyway there's no issue with making the parent device be part of that API.
Yeah, I misunderstood how the registration worked. It is fine as is, ignore my comments :-).
~Ryan
Signature · 7 lines
Bluewater Systems Ltd - ARM Technology Solution Centre Ryan Mallon 5 Amuri Park, 404 Barbadoes St ryan at bluewatersys.com PO Box 13 889, Christchurch 8013 http://www.bluewatersys.com New Zealand Phone: +64 3 3779127 Freecall: Australia 1800 148 751 Fax: +64 3 3779135 USA 1800 261 2934
PATCH v6 9/12 davinci: add tnetv107x evm ti-ssp gpio device
In reply to Cyril ChemparathyThis patch adds definitions to hook up one of the ti-ssp ports to the SSP GPIO driver.
--- arch/arm/mach-davinci/board-tnetv107x-evm.c | 11 +++++++++++ 1 files changed, 11 insertions(+), 0 deletions(-)
arch/arm/mach-davinci/board-tnetv107x-evm.c +11 -0
@@ -39,6 +39,8 @@#include <mach/cp_intc.h> #include <mach/tnetv107x.h> +#define SSP_GPIO_START 128 +#define EVM_MMC_WP_GPIO 21#define EVM_MMC_CD_GPIO 24#define EVM_SPI_CS_GPIO 54
@@ -238,9 +240,18 @@ static struct ti_ssp_spi_data spi_master_data = { SSP_INPUT_SEL(3), }; +static struct ti_ssp_gpio_data ssp_gpio_data = { + .start =SSP_GPIO_START , +}; +static struct ti_ssp_data ssp_config = { .out_clock =250 *1000 , .dev_data = { + [0 ] = { + .dev_name ="ti-ssp-gpio" , + .pdata = &ssp_gpio_data, + .pdata_size =sizeof (ssp_gpio_data), + }, [1 ] = { .dev_name ="ti-ssp-spi" , .pdata = &spi_master_data,
Signature · 1 line
1.7.1
PATCH v6 10/12 backlight: add support for tps6116x controller
In reply to Cyril ChemparathyTPS6116x is an EasyScale backlight controller device. This driver supports TPS6116x devices connected on a single GPIO.
--- drivers/video/backlight/Kconfig | 7 + drivers/video/backlight/Makefile | 2 +- drivers/video/backlight/tps6116x.c | 298 ++++++++++++++++++++++++++++++++++++ 3 files changed, 306 insertions(+), 1 deletions(-) create mode 100644 drivers/video/backlight/tps6116x.c
drivers/video/backlight/Kconfig +7 -0
@@ -307,6 +307,13 @@ config BACKLIGHT_PCF50633 If you have a backlight driven by a NXP PCF50633 MFD, say Y here to enable its driver. +config BACKLIGHT_TPS6116X + tristate "TPS6116X LCD Backlight" + depends on GENERIC_GPIO + help + This driver controls the LCD backlight level for EasyScale capable + SSP connected backlight controllers. + endif # BACKLIGHT_CLASS_DEVICE endif # BACKLIGHT_LCD_SUPPORT
drivers/video/backlight/Makefile +1 -1
@@ -35,4 +35,4 @@ obj-$(CONFIG_BACKLIGHT_ADP5520) += adp5520_bl.o obj-$(CONFIG_BACKLIGHT_ADP8860) += adp8860_bl.o obj-$(CONFIG_BACKLIGHT_88PM860X) += 88pm860x_bl.o obj-$(CONFIG_BACKLIGHT_PCF50633) += pcf50633-backlight.o - +obj-$(CONFIG_BACKLIGHT_TPS6116X)+= tps6116x.o
drivers/video/backlight/tps6116x.c new file +298 -0
298 lines not on this page · raw message
Signature · 1 line
1.7.1
PATCH v6 11/12 davinci: add tnetv107x evm backlight device
In reply to Cyril ChemparathyThe tnetv107x evm board has a backlight device that is connected on one of the SSP ports. This patch adds the board definitions necessary to plug the backlight driver to the GPIO corresponding to this SSP pin.
--- arch/arm/mach-davinci/board-tnetv107x-evm.c | 14 ++++++++++++++ 1 files changed, 14 insertions(+), 0 deletions(-)
arch/arm/mach-davinci/board-tnetv107x-evm.c +14 -0
@@ -44,6 +44,7 @@#define EVM_MMC_WP_GPIO 21#define EVM_MMC_CD_GPIO 24#define EVM_SPI_CS_GPIO 54 +#define EVM_BACKLIGHT_GPIO (SSP_GPIO_START + 2)static int initialize_gpio (int gpio,char *desc) {
@@ -353,6 +354,12 @@ static struct spi_board_info spi_info[] __initconst = { }, }; +static struct platform_device backlight_device = { + .name ="tps6116x" , + .id =-1 , + .dev.platform_data = (void *)EVM_BACKLIGHT_GPIO , +}; +static __init void tnetv107x_evm_board_init (void ) {davinci_cfg_reg_list (sdio1_pins);
@@ -364,6 +371,13 @@ static __init void tnetv107x_evm_board_init(void)spi_register_board_info (spi_info,ARRAY_SIZE (spi_info)); } +static int __init tnetv107x_evm_late_init (void ) +{ +platform_device_register (&backlight_device); +return 0 ; +} +late_initcall (tnetv107x_evm_late_init); +#ifdef CONFIG_SERIAL_8250_CONSOLE static int __init tnetv107x_evm_console_init (void ) {
Signature · 1 line
1.7.1
PATCH v6 11/12 davinci: add tnetv107x evm backlight device
Hello.
Quoted 14 lines · Cyril Chemparathy
The tnetv107x evm board has a backlight device that is connected on one of the SSP ports. This patch adds the board definitions necessary to plug the backlight driver to the GPIO corresponding to this SSP pin.
Signed-off-by Cyril Chemparathy <[email protected]>--- arch/arm/mach-davinci/board-tnetv107x-evm.c | 14 ++++++++++++++ 1 files changed, 14 insertions(+), 0 deletions(-)arch/arm/mach-davinci/board-tnetv107x-evm.c +0
-0
arch/arm/mach-davinci/board-tnetv107x-evm.c line 47
Quoted 4 lines
arch/arm/mach-davinci/board-tnetv107x-evm.c +1
-0@@ -44,6 +44,7 @@#define EVM_MMC_WP_GPIO 21#define EVM_MMC_CD_GPIO 24#define EVM_SPI_CS_GPIO 54 +#define EVM_BACKLIGHT_GPIO (SSP_GPIO_START + 2)
Why it's not aligned with others?
WBR, Sergei
PATCH v6 11/12 davinci: add tnetv107x evm backlight device
Quoted 13 lines · Sergei Shtylyov
Hello.
Quoted 8 lines · Cyril Chemparathy
The tnetv107x evm board has a backlight device that is connected on one of the SSP ports. This patch adds the board definitions necessary to plug the backlight driver to the GPIO corresponding to this SSP pin.
Signed-off-by Cyril Chemparathy <[email protected]>--- arch/arm/mach-davinci/board-tnetv107x-evm.c | 14 ++++++++++++++ 1 files changed, 14 insertions(+), 0 deletions(-)
Quoted 11 lines
arch/arm/mach-davinci/board-tnetv107x-evm.c line 47
Quoted 9 lines
arch/arm/mach-davinci/board-tnetv107x-evm.c +1
-0@@ -44,6 +44,7 @@#define EVM_MMC_WP_GPIO 21#define EVM_MMC_CD_GPIO 24#define EVM_SPI_CS_GPIO 54 +#define EVM_BACKLIGHT_GPIO (SSP_GPIO_START + 2)Why it's not aligned with others?
It actually is aligned if you remove the leading space/+.
Regards
Cyril.
PATCH v6 11/12 davinci: add tnetv107x evm backlight device
Hello.
Quoted 19 lines · Cyril Chemparathy
Quoted 10 lines
Quoted 10 lines
The tnetv107x evm board has a backlight device that is connected on one of the SSP ports. This patch adds the board definitions necessary to plug the backlight driver to the GPIO corresponding to this SSP pin.
Signed-off-by Cyril Chemparathy <[email protected]>--- arch/arm/mach-davinci/board-tnetv107x-evm.c | 14 ++++++++++++++ 1 files changed, 14 insertions(+), 0 deletions(-)arch/arm/mach-davinci/board-tnetv107x-evm.c +0
-1--- a/arch/arm/mach-davinci/board-tnetv107x-evm.cQuoted 8 lines
arch/arm/mach-davinci/board-tnetv107x-evm.c line 47
Quoted 6 lines
+++
b/arch/arm/mach-davinci/board-tnetv107x-evm.carch/arm/mach-davinci/board-tnetv107x-evm.c +1
-0@@ -44,6 +44,7 @@#define EVM_MMC_WP_GPIO 21#define EVM_MMC_CD_GPIO 24#define EVM_SPI_CS_GPIO 54 +#define EVM_BACKLIGHT_GPIO (SSP_GPIO_START + 2)Why it's not aligned with others?
Quoted 1 line
It actually is aligned if you remove the leading space/+.
Heh, realized that after sending. :-)
That's why I use spaces instead of one-space tab. Unfortunately,scripts/checkpatch.pl does not like it now... :-/
Quoted 2 lines
Regards
Cyril.
WBR, Sergei
PATCH v6 12/12 davinci: add tnetv107x evm i2c eeprom device
In reply to Cyril ChemparathyThe tnetv107x evm board has an I2C device connected on one of the SSP ports. This patch adds board definitions for a GPIO based I2C master, as well as definitions for the eeprom device on these boards.
--- arch/arm/mach-davinci/board-tnetv107x-evm.c | 30 +++++++++++++++++++++++++++ 1 files changed, 30 insertions(+), 0 deletions(-)
arch/arm/mach-davinci/board-tnetv107x-evm.c +30 -0
@@ -29,6 +29,9 @@#include <linux/regulator/machine.h> #include <linux/regulator/consumer.h> #include <linux/regulator/driver.h> +#include <linux/i2c.h> +#include <linux/i2c/at24.h> +#include <linux/i2c-gpio.h> #include <asm/mach/arch.h> #include <asm/mach-types.h>
@@ -44,6 +47,8 @@#define EVM_MMC_WP_GPIO 21#define EVM_MMC_CD_GPIO 24#define EVM_SPI_CS_GPIO 54 +#define EVM_I2C_SDA_GPIO (SSP_GPIO_START + 0) +#define EVM_I2C_SCL_GPIO (SSP_GPIO_START + 1)#define EVM_BACKLIGHT_GPIO (SSP_GPIO_START + 2)static int initialize_gpio (int gpio,char *desc)
@@ -360,6 +365,29 @@ static struct platform_device backlight_device = { .dev.platform_data = (void *)EVM_BACKLIGHT_GPIO, }; +struct i2c_gpio_platform_data i2c_data = { + .sda_pin =EVM_I2C_SDA_GPIO , + .scl_pin =EVM_I2C_SCL_GPIO , +}; + +static struct platform_device i2c_device = { + .name ="i2c-gpio" , + .id =0 , + .dev.platform_data = &i2c_data, +}; + +static struct at24_platform_data at24_config = { + .byte_len =SZ_16K /8 , + .page_size =16 , +}; + +static struct i2c_board_info i2c_info[]__initconst = { + { +I2C_BOARD_INFO ("24c16" ,0x50 ), + .platform_data = &at24_config, + }, +}; +static __init void tnetv107x_evm_board_init (void ) {davinci_cfg_reg_list (sdio1_pins);
@@ -369,11 +397,13 @@ static __init void tnetv107x_evm_board_init(void)tnetv107x_devices_init (&evm_device_info);spi_register_board_info (spi_info,ARRAY_SIZE (spi_info)); +i2c_register_board_info (0 , i2c_info,ARRAY_SIZE (i2c_info)); }static int __init tnetv107x_evm_late_init (void ) {platform_device_register (&backlight_device); +platform_device_register (&i2c_device);return 0 ; }late_initcall (tnetv107x_evm_late_init);
Signature · 1 line
1.7.1