si4713 DT binding
Subsystems (7)
cover si4713 DT binding
Hi,
This is an RFC patch adding DT support to the si4713 radio transmitter i2c driver. The changes can be summarized as follows:
* Move regulator information back into the driver. The regulators needed are documented in the chip and have nothing to do with boarddata. Instead devm_regulator_get_optional and errors are handled quite loosely now. Maybe the USB driver should provide dummy regulators.
* GPIO handling is updated to gpiod consumer interface, resulting in a driver cleanup and easy DT handling
* The driver is updated to use managed resources wherever possible
So much about the nice stuff. But there is also
* Instantiation of the platform device from the i2c (sub-)device. Since DT is not supposed to contain linuxisms the device is a simple i2c node resulting in the i2c probe function being called. Thus registering the main v4l device must happen from there.
Tested:
* Compilation on torvalds/linux.git:master
* Booting in DT mode
* Some simply driver queries using v4l2-ctl
Not tested:
* The USB driver, since I do not own the USB dongle
* The legacy platform code (only DT boot has been tested).
(The legacy platform code is supposed to removed in the near future anyways)
-- Sebastian
Sebastian Reichel (2):
[media] si4713: add Device Tree support
[media] Ad DT binding documentation for si4713
Documentation/devicetree/bindings/media/si4713.txt | 30 ++++ arch/arm/mach-omap2/board-rx51-peripherals.c | 67 ++++----- drivers/media/radio/si4713/radio-platform-si4713.c | 28 +--- drivers/media/radio/si4713/si4713.c | 166 +++++++++++++-------- drivers/media/radio/si4713/si4713.h | 15 +- include/media/radio-si4713.h | 30 ---- include/media/si4713.h | 4 +- 7 files changed, 183 insertions(+), 157 deletions(-) create mode 100644 Documentation/devicetree/bindings/media/si4713.txt delete mode 100644 include/media/radio-si4713.h
Signature · 6 lines
1.9.1 -- To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
RFC 1/2 si4713: add Device Tree support
Update si4713 driver to support being instantiated via Device Tree. This includes moving the regulator names back into the drivers, using regulator_get_optional to avoid breaking the USB driver and switching to the gpio resource interface.
--- arch/arm/mach-omap2/board-rx51-peripherals.c | 67 ++++----- drivers/media/radio/si4713/radio-platform-si4713.c | 28 +--- drivers/media/radio/si4713/si4713.c | 166 +++++++++++++-------- drivers/media/radio/si4713/si4713.h | 15 +- include/media/radio-si4713.h | 30 ---- include/media/si4713.h | 4 +- 6 files changed, 153 insertions(+), 157 deletions(-) delete mode 100644 include/media/radio-si4713.h
arch/arm/mach-omap2/board-rx51-peripherals.c +29 -38
@@ -23,6 +23,7 @@#include <linux/regulator/machine.h> #include <linux/gpio.h> #include <linux/gpio_keys.h> +#include <linux/gpio/driver.h> #include <linux/mmc/host.h> #include <linux/power/isp1704_charger.h> #include <linux/power/bq2415x_charger.h>
@@ -39,7 +40,6 @@#include <sound/tlv320aic3x.h> #include <sound/tpa6130a2-plat.h> -#include <media/radio-si4713.h> #include <media/si4713.h> #include <linux/platform_data/leds-lp55xx.h>
@@ -761,46 +761,17 @@ static struct regulator_init_data rx51_vintdig = { }, }; -static const char *const si4713_supply_names[] = { -"vio" , -"vdd" , -}; - -static struct si4713_platform_data rx51_si4713_i2c_data __initdata_or_module = { - .supplies =ARRAY_SIZE (si4713_supply_names), - .supply_names = si4713_supply_names, - .gpio_reset =RX51_FMTX_RESET_GPIO , -}; - -static struct i2c_board_info rx51_si4713_board_info __initdata_or_module = { -I2C_BOARD_INFO ("si4713" ,SI4713_I2C_ADDR_BUSEN_HIGH ), - .platform_data = &rx51_si4713_i2c_data, -}; - -static struct radio_si4713_platform_data rx51_si4713_data __initdata_or_module = { - .i2c_bus =2 , - .subdev_board_info = &rx51_si4713_board_info, -}; - -static struct platform_device rx51_si4713_dev __initdata_or_module = { - .name ="radio-si4713" , - .id =-1 , - .dev = { - .platform_data = &rx51_si4713_data, +static struct gpiod_lookup_table rx51_fmtx_gpios_table = { + .dev_id ="2-0063" , + .table = { +GPIO_LOOKUP ("gpio.6" ,3 ,"reset" ,GPIO_ACTIVE_HIGH ),/* 163 */ + { }, }, }; -static __init void rx51_init_si4713 (void ) +static __init void rx51_gpio_init (void ) { -int err; - - err =gpio_request_one (RX51_FMTX_IRQ ,GPIOF_DIR_IN ,"si4713 irq" ); -if (err) { -printk (KERN_ERR "Cannot request si4713 irq gpio. %d\n" , err); -return ; - } - rx51_si4713_board_info.irq =gpio_to_irq (RX51_FMTX_IRQ ); -platform_device_register (&rx51_si4713_dev); +gpiod_add_lookup_table (&rx51_fmtx_gpios_table); }static int rx51_twlgpio_setup (struct device *dev,unsigned gpio,unsigned n)
@@ -1040,7 +1011,17 @@ static struct bq2415x_platform_data rx51_bq24150a_platform_data = { .notify_device = "isp1704", }; +static struct si4713_platform_data rx51_si4713_platform_data = { + .is_platform_device = true +}; +static struct i2c_board_info __initdata rx51_peripherals_i2c_board_info_2[] = { +#if IS_ENABLED(CONFIG_I2C_SI4713) && IS_ENABLED(CONFIG_PLATFORM_SI4713) + { +I2C_BOARD_INFO ("si4713" ,0x63 ), + .platform_data = &rx51_si4713_platform_data, + }, +#endif {I2C_BOARD_INFO ("tlv320aic3x" ,0x18 ), .platform_data = &rx51_aic3x_data,
@@ -1085,6 +1066,8 @@ static struct i2c_board_info __initdata rx51_peripherals_i2c_board_info_3[] = {static int __init rx51_i2c_init (void ) { +int err; +if ((system_rev >=SYSTEM_REV_S_USES_VAUX3 && system_rev <0x100 ) || system_rev >=SYSTEM_REV_B_USES_VAUX3 ) { rx51_twldata.vaux3 = &rx51_vaux3_mmc;
@@ -1102,6 +1085,14 @@ static int __init rx51_i2c_init(void) rx51_twldata.vdac->constraints.name ="VDAC" ;omap_pmic_init (1 ,2200 ,"twl5030" ,7 +OMAP_INTC_START , &rx51_twldata); +#if IS_ENABLED (CONFIG_I2C_SI4713 ) &&IS_ENABLED (CONFIG_PLATFORM_SI4713 ) + err =gpio_request_one (RX51_FMTX_IRQ ,GPIOF_DIR_IN ,"si4713 irq" ); +if (err) { +printk (KERN_ERR "Cannot request si4713 irq gpio. %d\n" , err); +return err; + } + rx51_peripherals_i2c_board_info_2[0 ].irq =gpio_to_irq (RX51_FMTX_IRQ ); +#endif omap_register_i2c_bus (2 ,100 , rx51_peripherals_i2c_board_info_2,ARRAY_SIZE (rx51_peripherals_i2c_board_info_2));#if defined(CONFIG_SENSORS_LIS3_I2C ) || defined(CONFIG_SENSORS_LIS3_I2C_MODULE )
@@ -1315,6 +1306,7 @@ static void __init rx51_init_omap3_rom_rng(void)void __init rx51_peripherals_init (void ) { +rx51_gpio_init ();rx51_i2c_init ();regulator_has_full_constraints ();gpmc_onenand_init (board_onenand_data);
@@ -1322,7 +1314,6 @@ void __init rx51_peripherals_init(void)rx51_add_gpio_keys ();rx51_init_wl1251 ();rx51_init_tsc2005 (); -rx51_init_si4713 ();rx51_init_lirc ();spi_register_board_info (rx51_peripherals_spi_board_info,ARRAY_SIZE (rx51_peripherals_spi_board_info));
drivers/media/radio/si4713/radio-platform-si4713.c +6 -22
@@ -34,7 +34,7 @@#include <media/v4l2-fh.h> #include <media/v4l2-ctrls.h> #include <media/v4l2-event.h> -#include <media/radio-si4713.h> +#include "si4713.h" /* module parameters */ static int radio_nr =-1 ;/* radio device minor (-1 ==> auto assign) */
@@ -153,7 +153,6 @@ static int radio_si4713_pdriver_probe(struct platform_device *pdev) {struct radio_si4713_platform_data *pdata = pdev->dev.platform_data;struct radio_si4713_device *rsdev; -struct i2c_adapter *adapter;struct v4l2_subdev *sd;int rval =0 ;
@@ -177,20 +176,11 @@ static int radio_si4713_pdriver_probe(struct platform_device *pdev) goto exit; } - adapter =i2c_get_adapter (pdata->i2c_bus); -if (!adapter) { -dev_err (&pdev->dev,"Cannot get i2c adapter %d\n" , - pdata->i2c_bus); - rval = -ENODEV ; - goto unregister_v4l2_dev; - } - - sd =v4l2_i2c_new_subdev_board (&rsdev->v4l2_dev, adapter, - pdata->subdev_board_info,NULL ); -if (!sd) { + sd =i2c_get_clientdata (pdata->subdev); + rval =v4l2_device_register_subdev (&rsdev->v4l2_dev, sd); +if (rval) {dev_err (&pdev->dev,"Cannot get v4l2 subdevice\n" ); - rval = -ENODEV ; - goto put_adapter; + goto unregister_v4l2_dev; } rsdev->radio_dev = radio_si4713_vdev_template;
@@ -203,14 +193,12 @@ static int radio_si4713_pdriver_probe(struct platform_device *pdev)if (video_register_device (&rsdev->radio_dev,VFL_TYPE_RADIO , radio_nr)) {dev_err (&pdev->dev,"Could not register video device.\n" ); rval = -EIO ; - goto put_adapter; + goto unregister_v4l2_dev; }dev_info (&pdev->dev,"New device successfully probed\n" ); goto exit; -put_adapter: -i2c_put_adapter (adapter); unregister_v4l2_dev:v4l2_device_unregister (&rsdev->v4l2_dev); exit:
@@ -221,14 +209,10 @@ exit:static int radio_si4713_pdriver_remove (struct platform_device *pdev) {struct v4l2_device *v4l2_dev =platform_get_drvdata (pdev); -struct v4l2_subdev *sd =list_entry (v4l2_dev->subdevs.next, - struct v4l2_subdev, list); -struct i2c_client *client =v4l2_get_subdevdata (sd);struct radio_si4713_device *rsdev; rsdev = container_of(v4l2_dev, struct radio_si4713_device, v4l2_dev);video_unregister_device (&rsdev->radio_dev); -i2c_put_adapter (client->adapter);v4l2_device_unregister (&rsdev->v4l2_dev);return 0 ;
drivers/media/radio/si4713/si4713.c +107 -59
248 lines not on this page · raw message
drivers/media/radio/si4713/si4713.h +10 -5
@@ -15,7 +15,9 @@#ifndef SI4713_I2C_H #define SI4713_I2C_H +#include <linux/platform_device.h> #include <linux/regulator/consumer.h> +#include <linux/gpio/consumer.h> #include <media/v4l2-subdev.h> #include <media/v4l2-ctrls.h> #include <media/si4713.h>
@@ -190,8 +192,6 @@#define MIN_ACOMP_THRESHOLD (-40)#define MAX_ACOMP_GAIN 20 -#define SI4713_NUM_SUPPLIES 2 -/* * si4713_device - private data */
@@ -227,9 +227,10 @@ struct si4713_device {struct v4l2_ctrl *tune_ant_cap; };struct completion work; -unsigned supplies; -struct regulator_bulk_data supply_data[SI4713_NUM_SUPPLIES ]; -int gpio_reset; +struct regulator *vdd; +struct regulator *vio; +struct gpio_desc *gpio_reset; +struct platform_device *pd;u32 power_state;u32 rds_enabled;u32 frequency;
@@ -237,4 +238,8 @@ struct si4713_device {u32 stereo; u32 tune_rnl; }; + +struct radio_si4713_platform_data { +struct i2c_client *subdev; +};#endif /* ifndef SI4713_I2C_H */
include/media/radio-si4713.h deleted +0 -30
@@ -1,30 +0,0 @@ -/* -* include/media/radio-si4713.h -* -* Board related data definitions for Si4713 radio transmitter chip. -* -* Copyright (c) 2009 Nokia Corporation -* Contact: Eduardo Valentin <[email protected]> -* -* This file is licensed under the terms of the GNU General Public License -* version 2. This program is licensed "as is" without any warranty of any -* kind, whether express or implied. -* -*/ - -#ifndef RADIO_SI4713_H -#define RADIO_SI4713_H - -#include <linux/i2c.h> - -#define SI4713_NAME "radio-si4713" - -/* -* Platform dependent definition -*/ -struct radio_si4713_platform_data { -int i2c_bus; -struct i2c_board_info *subdev_board_info; -}; - -#endif /* ifndef RADIO_SI4713_H*/
include/media/si4713.h +1 -3
@@ -23,9 +23,7 @@* Platform dependent definition */ struct si4713_platform_data { -const char *const *supply_names; -unsigned supplies; -int gpio_reset;/* < 0 if not used */ +bool is_platform_device; };/*
Signature · 1 line
1.9.1
RFC 2/2 Ad DT binding documentation for si4713
In reply to Sebastian ReichelThis patch adds the DT bindings documentation for Silicon Labs Si4713 FM radio transmitter.
--- Documentation/devicetree/bindings/media/si4713.txt | 30 ++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 Documentation/devicetree/bindings/media/si4713.txt
Documentation/devicetree/bindings/media/si4713.txt new file +30 -0
@@ -0,0 +1,30 @@ +* Silicon Labs FM Radio transmitter + +The Silicon Labs Si4713 is an FM radio transmitter with receive power scan +supporting 76-108 MHz. It includes an RDS encoder and has both, a stereo-analog +and a digital interface, which supports I2S, left-justified and a custom +DSP-mode format. It is programmable through an I2C interface. + +Required Properties: +- compatible: Should contain "silabs,si4713" +- reg: the I2C address of the device + +Optional Properties: +- interrupts-extended: Interrupt specifier for the chips interrupt +- reset-gpios: GPIO specifier for the chips reset line +- vdd-supply: phandle for Vdd regulator +- vio-supply: phandle for Vio regulator + +Example: + +&i2c2 { + fmtx: si4713@63 { + compatible = "silabs,si4713"; + reg = <0x63>; + + interrupts-extended = <&gpio2 21 IRQ_TYPE_EDGE_FALLING>; /* 53 */ + reset-gpios = <&gpio6 3 GPIO_ACTIVE_HIGH>; /* 163 */ + vio-supply = <&vio>; + vdd-supply = <&vaux1>; + }; +};
Signature · 1 line
1.9.1
Quoted 2 lines · Sebastian Reichel
This is an RFC patch adding DT support to the si4713 radio transmitter i2c driver.
ping?
-- Sebastian