Update sunxi-next and sun8i-dev overlays
This commit is contained in:
parent
71d89e856d
commit
5c5b80b694
174
patch/kernel/sun8i-dev/add-ad9834-dt-bindings.patch
Normal file
174
patch/kernel/sun8i-dev/add-ad9834-dt-bindings.patch
Normal file
@ -0,0 +1,174 @@
|
||||
diff --git a/drivers/staging/iio/frequency/ad9834.c b/drivers/staging/iio/frequency/ad9834.c
|
||||
index 19216af1..e839d23a 100644
|
||||
--- a/drivers/staging/iio/frequency/ad9834.c
|
||||
+++ b/drivers/staging/iio/frequency/ad9834.c
|
||||
@@ -13,11 +13,14 @@
|
||||
#include <linux/slab.h>
|
||||
#include <linux/sysfs.h>
|
||||
#include <linux/list.h>
|
||||
+#include <linux/of.h>
|
||||
+#include <linux/of_device.h>
|
||||
#include <linux/spi/spi.h>
|
||||
#include <linux/regulator/consumer.h>
|
||||
#include <linux/err.h>
|
||||
#include <linux/module.h>
|
||||
#include <asm/div64.h>
|
||||
+#include <linux/clk.h>
|
||||
|
||||
#include <linux/iio/iio.h>
|
||||
#include <linux/iio/sysfs.h>
|
||||
@@ -316,14 +319,81 @@ static const struct iio_info ad9833_info = {
|
||||
.driver_module = THIS_MODULE,
|
||||
};
|
||||
|
||||
+#if defined(CONFIG_OF)
|
||||
+static struct ad9834_platform_data *ad9834_parse_dt(struct spi_device *spi)
|
||||
+{
|
||||
+ struct ad9834_platform_data *pdata;
|
||||
+ struct device_node *np = spi->dev.of_node;
|
||||
+
|
||||
+ pdata = devm_kzalloc(&spi->dev, sizeof(*pdata), GFP_KERNEL);
|
||||
+ if (!pdata)
|
||||
+ return ERR_PTR(-ENOMEM);
|
||||
+
|
||||
+ pdata->freq0 = 134000;
|
||||
+ of_property_read_u32(np, "freq0", &pdata->freq0);
|
||||
+
|
||||
+ pdata->freq1 = 134000;
|
||||
+ of_property_read_u32(np, "freq1", &pdata->freq1);
|
||||
+
|
||||
+ pdata->phase0 = 0;
|
||||
+ of_property_read_u16(np, "phase0", &pdata->phase0);
|
||||
+
|
||||
+ pdata->phase1 = 0;
|
||||
+ of_property_read_u16(np, "phase1", &pdata->phase1);
|
||||
+
|
||||
+ pdata->en_div2 = of_property_read_bool(np, "en_div2");
|
||||
+ pdata->en_signbit_msb_out = of_property_read_bool(np,
|
||||
+ "en_signbit_msb_out");
|
||||
+
|
||||
+ return pdata;
|
||||
+}
|
||||
+#else
|
||||
+static struct ad9834_platform_data *ad9834_parse_dt(struct spi_device *spi)
|
||||
+{
|
||||
+ return NULL;
|
||||
+}
|
||||
+#endif
|
||||
+
|
||||
+static const struct of_device_id ad9834_of_match[] = {
|
||||
+ {
|
||||
+ .compatible = "adi,ad9833",
|
||||
+ .data = (void *)ID_AD9833,
|
||||
+ },
|
||||
+ {
|
||||
+ .compatible = "adi,ad9834",
|
||||
+ .data = (void *)ID_AD9834,
|
||||
+ },
|
||||
+ {
|
||||
+ .compatible = "adi,ad9837",
|
||||
+ .data = (void *)ID_AD9837,
|
||||
+ },
|
||||
+ {
|
||||
+ .compatible = "adi,ad9838",
|
||||
+ .data = (void *)ID_AD9838,
|
||||
+ },
|
||||
+ { }
|
||||
+};
|
||||
+MODULE_DEVICE_TABLE(of, ad9834_of_match);
|
||||
+
|
||||
static int ad9834_probe(struct spi_device *spi)
|
||||
{
|
||||
- struct ad9834_platform_data *pdata = dev_get_platdata(&spi->dev);
|
||||
+ const struct of_device_id *of_id = of_match_device(ad9834_of_match,
|
||||
+ &spi->dev);
|
||||
+ struct ad9834_platform_data *pdata;
|
||||
struct ad9834_state *st;
|
||||
struct iio_dev *indio_dev;
|
||||
struct regulator *reg;
|
||||
+ struct clk *clk = NULL;
|
||||
int ret;
|
||||
|
||||
+ if (!pdata && spi->dev.of_node) {
|
||||
+ pdata = ad9834_parse_dt(spi);
|
||||
+ if (IS_ERR(pdata))
|
||||
+ return PTR_ERR(pdata);
|
||||
+ } else {
|
||||
+ pdata = spi->dev.platform_data;
|
||||
+ }
|
||||
+
|
||||
if (!pdata) {
|
||||
dev_dbg(&spi->dev, "no platform data?\n");
|
||||
return -ENODEV;
|
||||
@@ -346,9 +416,30 @@ static int ad9834_probe(struct spi_device *spi)
|
||||
}
|
||||
spi_set_drvdata(spi, indio_dev);
|
||||
st = iio_priv(indio_dev);
|
||||
- st->mclk = pdata->mclk;
|
||||
+
|
||||
+ if (!pdata->mclk) {
|
||||
+ clk = devm_clk_get(&spi->dev, NULL);
|
||||
+ if (IS_ERR(clk))
|
||||
+ return -EPROBE_DEFER;
|
||||
+
|
||||
+ ret = clk_prepare_enable(clk);
|
||||
+ if (ret < 0)
|
||||
+ return ret;
|
||||
+ }
|
||||
+
|
||||
+ if (clk) {
|
||||
+ st->clk = clk;
|
||||
+ st->mclk = clk_get_rate(clk);
|
||||
+ } else {
|
||||
+ st->mclk = pdata->mclk;
|
||||
+ }
|
||||
+
|
||||
+ if (of_id)
|
||||
+ st->devid = (enum ad9834_supported_device_ids)of_id->data;
|
||||
+ else
|
||||
+ st->devid = spi_get_device_id(spi)->driver_data;
|
||||
+
|
||||
st->spi = spi;
|
||||
- st->devid = spi_get_device_id(spi)->driver_data;
|
||||
st->reg = reg;
|
||||
indio_dev->dev.parent = &spi->dev;
|
||||
indio_dev->name = spi_get_device_id(spi)->name;
|
||||
@@ -421,6 +512,9 @@ static int ad9834_probe(struct spi_device *spi)
|
||||
error_disable_reg:
|
||||
regulator_disable(reg);
|
||||
|
||||
+if (clk)
|
||||
+ clk_disable_unprepare(clk);
|
||||
+
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -431,6 +525,8 @@ static int ad9834_remove(struct spi_device *spi)
|
||||
|
||||
iio_device_unregister(indio_dev);
|
||||
regulator_disable(st->reg);
|
||||
+if (st->clk)
|
||||
+ clk_disable_unprepare(st->clk);
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -447,6 +543,7 @@ MODULE_DEVICE_TABLE(spi, ad9834_id);
|
||||
static struct spi_driver ad9834_driver = {
|
||||
.driver = {
|
||||
.name = "ad9834",
|
||||
+ .of_match_table = of_match_ptr(ad9834_of_match),
|
||||
},
|
||||
.probe = ad9834_probe,
|
||||
.remove = ad9834_remove,
|
||||
diff --git a/drivers/staging/iio/frequency/ad9834.h b/drivers/staging/iio/frequency/ad9834.h
|
||||
index 40fdd5da..fd9cccf3 100644
|
||||
--- a/drivers/staging/iio/frequency/ad9834.h
|
||||
+++ b/drivers/staging/iio/frequency/ad9834.h
|
||||
@@ -53,6 +53,7 @@
|
||||
struct ad9834_state {
|
||||
struct spi_device *spi;
|
||||
struct regulator *reg;
|
||||
+ struct clk *clk;
|
||||
unsigned int mclk;
|
||||
unsigned short control;
|
||||
unsigned short devid;
|
||||
@ -51,13 +51,13 @@ index 00000000..4750a425
|
||||
+clean-files := *.dtbo *.scr
|
||||
diff --git a/arch/arm/boot/dts/overlay/README.sun8i-h3-overlays b/arch/arm/boot/dts/overlay/README.sun8i-h3-overlays
|
||||
new file mode 100644
|
||||
index 00000000..e5d55da1
|
||||
index 00000000..996308c9
|
||||
--- /dev/null
|
||||
+++ b/arch/arm/boot/dts/overlay/README.sun8i-h3-overlays
|
||||
@@ -0,0 +1,286 @@
|
||||
@@ -0,0 +1,297 @@
|
||||
+This document describes overlays provided in the kernel packages
|
||||
+For generic Armbian overlays documentation please see
|
||||
+https://docs.armbian.com/Hardware_Allwinner_overlays/
|
||||
+https://docs.armbian.com/User-Guide_Allwinner_overlays/
|
||||
+
|
||||
+### Platform:
|
||||
+
|
||||
@ -80,6 +80,7 @@ index 00000000..e5d55da1
|
||||
+- i2c-ds1307
|
||||
+- pps-gpio
|
||||
+- pwm
|
||||
+- spdif-out
|
||||
+- spi-add-cs1
|
||||
+- spi-jedec-nor
|
||||
+- spi-mcp2515
|
||||
@ -163,12 +164,21 @@ index 00000000..e5d55da1
|
||||
+Pin PA5 is used as UART0 RX by default, so if this overlay is activated,
|
||||
+UART0 and kernel console on ttyS0 will be disabled
|
||||
+
|
||||
+### spdif-out
|
||||
+
|
||||
+Activates SPDIF/Toslink audio output
|
||||
+
|
||||
+SPDIF pin: PA17
|
||||
+
|
||||
+### spi-add-cs1
|
||||
+
|
||||
+Adds support for using SPI chip select 1 with GPIO for both SPI controllers
|
||||
+Respective GPIO will be claimed only if controller is enabled by another
|
||||
+overlay
|
||||
+This overlay is required for using chip select 1 with other SPI overlays
|
||||
+Due to the u-boot limitations CS1 pin can't be customized by a parameter, but
|
||||
+it can be changed by using an edited copy of this overlay
|
||||
+A total of 4 chip selects can be used with custom overlays (1 HW + 3 GPIO)
|
||||
+
|
||||
+SPI 0 pins (CS1): PA21
|
||||
+SPI 1 pins (CS1): PA10
|
||||
@ -325,7 +335,8 @@ index 00000000..e5d55da1
|
||||
+### w1-gpio
|
||||
+
|
||||
+Activates 1-Wire GPIO master
|
||||
+Requires external pull-up resistor on data pin
|
||||
+Requires an external pull-up resistor on the data pin
|
||||
+or enabling the internal pull-up
|
||||
+
|
||||
+Parameters:
|
||||
+
|
||||
@ -746,6 +757,49 @@ index 00000000..1d2b6a7d
|
||||
+ };
|
||||
+ };
|
||||
+};
|
||||
diff --git a/arch/arm/boot/dts/overlay/sun8i-h3-spdif-out.dts b/arch/arm/boot/dts/overlay/sun8i-h3-spdif-out.dts
|
||||
new file mode 100644
|
||||
index 00000000..0d5a3470
|
||||
--- /dev/null
|
||||
+++ b/arch/arm/boot/dts/overlay/sun8i-h3-spdif-out.dts
|
||||
@@ -0,0 +1,37 @@
|
||||
+/dts-v1/ /plugin/;
|
||||
+
|
||||
+/ {
|
||||
+ compatible = "allwinner,sun8i-h3";
|
||||
+
|
||||
+ fragment@0 {
|
||||
+ target = <&spdif>;
|
||||
+ __overlay__ {
|
||||
+ pinctrl-names = "default";
|
||||
+ pinctrl-0 = <&spdif_tx_pins_a>;
|
||||
+ status = "okay";
|
||||
+ };
|
||||
+ };
|
||||
+
|
||||
+ fragment@1 {
|
||||
+ target-path = "/";
|
||||
+ __overlay__ {
|
||||
+ sound {
|
||||
+ compatible = "simple-audio-card";
|
||||
+ simple-audio-card,name = "On-board SPDIF";
|
||||
+
|
||||
+ simple-audio-card,cpu {
|
||||
+ sound-dai = <&spdif>;
|
||||
+ };
|
||||
+
|
||||
+ simple-audio-card,codec {
|
||||
+ sound-dai = <&spdif_out>;
|
||||
+ };
|
||||
+ };
|
||||
+
|
||||
+ spdif_out: spdif-out {
|
||||
+ #sound-dai-cells = <0>;
|
||||
+ compatible = "linux,spdif-dit";
|
||||
+ };
|
||||
+ };
|
||||
+ };
|
||||
+};
|
||||
diff --git a/arch/arm/boot/dts/overlay/sun8i-h3-spi-add-cs1.dts b/arch/arm/boot/dts/overlay/sun8i-h3-spi-add-cs1.dts
|
||||
new file mode 100644
|
||||
index 00000000..021cf435
|
||||
|
||||
@ -12,10 +12,10 @@ index 01d178a2..bfba239c 100644
|
||||
+dts-dirs += overlay
|
||||
diff --git a/arch/arm/boot/dts/overlay/Makefile b/arch/arm/boot/dts/overlay/Makefile
|
||||
new file mode 100644
|
||||
index 00000000..ec753791
|
||||
index 00000000..18fa1c75
|
||||
--- /dev/null
|
||||
+++ b/arch/arm/boot/dts/overlay/Makefile
|
||||
@@ -0,0 +1,61 @@
|
||||
@@ -0,0 +1,60 @@
|
||||
+ifeq ($(CONFIG_OF_CONFIGFS),y)
|
||||
+
|
||||
+dtbo-$(CONFIG_MACH_SUN4I) += \
|
||||
@ -45,7 +45,6 @@ index 00000000..ec753791
|
||||
+ sun7i-a20-i2c1.dtbo \
|
||||
+ sun7i-a20-i2c2.dtbo \
|
||||
+ sun7i-a20-i2c3.dtbo \
|
||||
+ sun7i-a20-i2c3-edt-ft5x06.dtbo \
|
||||
+ sun7i-a20-i2c4.dtbo \
|
||||
+ sun7i-a20-i2c-ds1307.dtbo \
|
||||
+ sun7i-a20-mmc2.dtbo \
|
||||
@ -79,13 +78,13 @@ index 00000000..ec753791
|
||||
+clean-files := *.dtbo *.scr
|
||||
diff --git a/arch/arm/boot/dts/overlay/README.sun4i-a10-overlays b/arch/arm/boot/dts/overlay/README.sun4i-a10-overlays
|
||||
new file mode 100644
|
||||
index 00000000..ffe5f091
|
||||
index 00000000..c5093b56
|
||||
--- /dev/null
|
||||
+++ b/arch/arm/boot/dts/overlay/README.sun4i-a10-overlays
|
||||
@@ -0,0 +1,306 @@
|
||||
@@ -0,0 +1,307 @@
|
||||
+This document describes overlays provided in the kernel packages
|
||||
+For generic Armbian overlays documentation please see
|
||||
+https://docs.armbian.com/Hardware_Allwinner_overlays/
|
||||
+https://docs.armbian.com/User-Guide_Allwinner_overlays/
|
||||
+
|
||||
+### Platform:
|
||||
+
|
||||
@ -373,7 +372,8 @@ index 00000000..ffe5f091
|
||||
+### w1-gpio
|
||||
+
|
||||
+Activates 1-Wire GPIO master
|
||||
+Requires external pull-up resistor on data pin
|
||||
+Requires an external pull-up resistor on the data pin
|
||||
+or enabling the internal pull-up
|
||||
+
|
||||
+Parameters:
|
||||
+
|
||||
@ -391,13 +391,13 @@ index 00000000..ffe5f091
|
||||
+ please use external pull-up resistor instead
|
||||
diff --git a/arch/arm/boot/dts/overlay/README.sun7i-a20-overlays b/arch/arm/boot/dts/overlay/README.sun7i-a20-overlays
|
||||
new file mode 100644
|
||||
index 00000000..51cb9ee5
|
||||
index 00000000..b676bc3f
|
||||
--- /dev/null
|
||||
+++ b/arch/arm/boot/dts/overlay/README.sun7i-a20-overlays
|
||||
@@ -0,0 +1,364 @@
|
||||
@@ -0,0 +1,371 @@
|
||||
+This document describes overlays provided in the kernel packages
|
||||
+For generic Armbian overlays documentation please see
|
||||
+https://docs.armbian.com/Hardware_Allwinner_overlays/
|
||||
+https://docs.armbian.com/User-Guide_Allwinner_overlays/
|
||||
+
|
||||
+### Platform:
|
||||
+
|
||||
@ -490,18 +490,24 @@ index 00000000..51cb9ee5
|
||||
+
|
||||
+### mmc2
|
||||
+
|
||||
+Activates SD/MMC controller 2. To be used on boards with second SD slot
|
||||
+instead of NAND storage.
|
||||
+Activates SD/MMC controller 2. To be used on boards with second SD slot, eMMC
|
||||
+or tSD instead of NAND storage.
|
||||
+
|
||||
+MMC2 pins: PC6, PC7, PC8, PC9, PC10, PC11
|
||||
+
|
||||
+Parameters:
|
||||
+
|
||||
+param_mmc2_cd_pin (pin)
|
||||
+ MMC 2 card detect pin
|
||||
+ SD/MMC 2 card detect pin
|
||||
+ Optional
|
||||
+ Default: PH0
|
||||
+
|
||||
+param_mmc2_non_removable (bool)
|
||||
+ Option for non-removable storage options on MMC 2 controller (eMMC or tSD)
|
||||
+ Optional
|
||||
+ Default: 0
|
||||
+ Set to 1 to use this option
|
||||
+
|
||||
+### nand
|
||||
+
|
||||
+Activates NAND controller
|
||||
@ -743,7 +749,8 @@ index 00000000..51cb9ee5
|
||||
+### w1-gpio
|
||||
+
|
||||
+Activates 1-Wire GPIO master
|
||||
+Requires external pull-up resistor on data pin
|
||||
+Requires an external pull-up resistor on the data pin
|
||||
+or enabling the internal pull-up
|
||||
+
|
||||
+Parameters:
|
||||
+
|
||||
@ -1867,10 +1874,10 @@ index 00000000..8ab3fb01
|
||||
+};
|
||||
diff --git a/arch/arm/boot/dts/overlay/sun7i-a20-fixup.scr-cmd b/arch/arm/boot/dts/overlay/sun7i-a20-fixup.scr-cmd
|
||||
new file mode 100644
|
||||
index 00000000..a71e74fa
|
||||
index 00000000..3edaae92
|
||||
--- /dev/null
|
||||
+++ b/arch/arm/boot/dts/overlay/sun7i-a20-fixup.scr-cmd
|
||||
@@ -0,0 +1,161 @@
|
||||
@@ -0,0 +1,166 @@
|
||||
+# overlays fixup script
|
||||
+# implements (or rather substitutes) overlay arguments functionality
|
||||
+# using u-boot scripting, environment variables and "fdt" command
|
||||
@ -2008,6 +2015,11 @@ index 00000000..a71e74fa
|
||||
+ fdt set /soc@01c00000/mmc@01c11000 cd-gpios "<${tmp_phandle} ${tmp_bank} ${tmp_pin} 1>"
|
||||
+fi
|
||||
+
|
||||
+if test "${param_mmc2_non_removable}" = "1"; then
|
||||
+ fdt rm /soc@01c00000/mmc@01c11000 cd-gpios
|
||||
+ fdt set /soc@01c00000/mmc@01c11000 non-removable
|
||||
+fi
|
||||
+
|
||||
+if test "${param_w1_pin_int_pullup}" = "1"; then
|
||||
+ fdt set /soc@01c00000/pinctrl@01c20800/w1_pins bias-pull-up
|
||||
+fi
|
||||
@ -2173,55 +2185,6 @@ index 00000000..db4478fb
|
||||
+ };
|
||||
+ };
|
||||
+};
|
||||
diff --git a/arch/arm/boot/dts/overlay/sun7i-a20-i2c3-edt-ft5x06.dts b/arch/arm/boot/dts/overlay/sun7i-a20-i2c3-edt-ft5x06.dts
|
||||
new file mode 100644
|
||||
index 00000000..e884fdc1
|
||||
--- /dev/null
|
||||
+++ b/arch/arm/boot/dts/overlay/sun7i-a20-i2c3-edt-ft5x06.dts
|
||||
@@ -0,0 +1,43 @@
|
||||
+/dts-v1/ /plugin/;
|
||||
+
|
||||
+#include <dt-bindings/interrupt-controller/arm-gic.h>
|
||||
+#include <dt-bindings/gpio/gpio.h>
|
||||
+
|
||||
+/ {
|
||||
+ compatible = "allwinner,sun7i-a20";
|
||||
+
|
||||
+ fragment@0 {
|
||||
+ target = <&pio>;
|
||||
+ __overlay__ {
|
||||
+ edt_ft5x06_pins: edt_ft5x06_pins {
|
||||
+ pins = "PH7", "PH9";
|
||||
+ function = "gpio_out";
|
||||
+ };
|
||||
+ };
|
||||
+ };
|
||||
+
|
||||
+ fragment@1 {
|
||||
+ target = <&i2c3>;
|
||||
+ __overlay__ {
|
||||
+ #address-cells = <1>;
|
||||
+ #size-cells = <0>;
|
||||
+ status = "okay";
|
||||
+ pinctrl-names = "default";
|
||||
+ pinctrl-0 = <&i2c3_pins_a>;
|
||||
+ edt: edt-ft5x06@38 {
|
||||
+ compatible = "edt,edt-ft5x06";
|
||||
+ reg = <0x38>;
|
||||
+ interrupt-parent = <&pio>;
|
||||
+ interrupts = <7 9 IRQ_TYPE_EDGE_FALLING>;
|
||||
+ wake-gpios = <7 7 GPIO_ACTIVE_LOW>;
|
||||
+ pinctrl-names = "default";
|
||||
+ pinctrl-0 = <&edt_ft5x06_pins>;
|
||||
+ touchscreen-size-x = <1024>;
|
||||
+ touchscreen-size-y = <600>;
|
||||
+ touchscreen-inverted-x;
|
||||
+ touchscreen-swapped-x-y;
|
||||
+ };
|
||||
+ };
|
||||
+
|
||||
+ };
|
||||
+};
|
||||
diff --git a/arch/arm/boot/dts/overlay/sun7i-a20-i2c3.dts b/arch/arm/boot/dts/overlay/sun7i-a20-i2c3.dts
|
||||
new file mode 100644
|
||||
index 00000000..a04e0264
|
||||
|
||||
174
patch/kernel/sunxi-next/add-ad9834-dt-bindings.patch
Normal file
174
patch/kernel/sunxi-next/add-ad9834-dt-bindings.patch
Normal file
@ -0,0 +1,174 @@
|
||||
diff --git a/drivers/staging/iio/frequency/ad9834.c b/drivers/staging/iio/frequency/ad9834.c
|
||||
index 19216af1..e839d23a 100644
|
||||
--- a/drivers/staging/iio/frequency/ad9834.c
|
||||
+++ b/drivers/staging/iio/frequency/ad9834.c
|
||||
@@ -13,11 +13,14 @@
|
||||
#include <linux/slab.h>
|
||||
#include <linux/sysfs.h>
|
||||
#include <linux/list.h>
|
||||
+#include <linux/of.h>
|
||||
+#include <linux/of_device.h>
|
||||
#include <linux/spi/spi.h>
|
||||
#include <linux/regulator/consumer.h>
|
||||
#include <linux/err.h>
|
||||
#include <linux/module.h>
|
||||
#include <asm/div64.h>
|
||||
+#include <linux/clk.h>
|
||||
|
||||
#include <linux/iio/iio.h>
|
||||
#include <linux/iio/sysfs.h>
|
||||
@@ -316,14 +319,81 @@ static const struct iio_info ad9833_info = {
|
||||
.driver_module = THIS_MODULE,
|
||||
};
|
||||
|
||||
+#if defined(CONFIG_OF)
|
||||
+static struct ad9834_platform_data *ad9834_parse_dt(struct spi_device *spi)
|
||||
+{
|
||||
+ struct ad9834_platform_data *pdata;
|
||||
+ struct device_node *np = spi->dev.of_node;
|
||||
+
|
||||
+ pdata = devm_kzalloc(&spi->dev, sizeof(*pdata), GFP_KERNEL);
|
||||
+ if (!pdata)
|
||||
+ return ERR_PTR(-ENOMEM);
|
||||
+
|
||||
+ pdata->freq0 = 134000;
|
||||
+ of_property_read_u32(np, "freq0", &pdata->freq0);
|
||||
+
|
||||
+ pdata->freq1 = 134000;
|
||||
+ of_property_read_u32(np, "freq1", &pdata->freq1);
|
||||
+
|
||||
+ pdata->phase0 = 0;
|
||||
+ of_property_read_u16(np, "phase0", &pdata->phase0);
|
||||
+
|
||||
+ pdata->phase1 = 0;
|
||||
+ of_property_read_u16(np, "phase1", &pdata->phase1);
|
||||
+
|
||||
+ pdata->en_div2 = of_property_read_bool(np, "en_div2");
|
||||
+ pdata->en_signbit_msb_out = of_property_read_bool(np,
|
||||
+ "en_signbit_msb_out");
|
||||
+
|
||||
+ return pdata;
|
||||
+}
|
||||
+#else
|
||||
+static struct ad9834_platform_data *ad9834_parse_dt(struct spi_device *spi)
|
||||
+{
|
||||
+ return NULL;
|
||||
+}
|
||||
+#endif
|
||||
+
|
||||
+static const struct of_device_id ad9834_of_match[] = {
|
||||
+ {
|
||||
+ .compatible = "adi,ad9833",
|
||||
+ .data = (void *)ID_AD9833,
|
||||
+ },
|
||||
+ {
|
||||
+ .compatible = "adi,ad9834",
|
||||
+ .data = (void *)ID_AD9834,
|
||||
+ },
|
||||
+ {
|
||||
+ .compatible = "adi,ad9837",
|
||||
+ .data = (void *)ID_AD9837,
|
||||
+ },
|
||||
+ {
|
||||
+ .compatible = "adi,ad9838",
|
||||
+ .data = (void *)ID_AD9838,
|
||||
+ },
|
||||
+ { }
|
||||
+};
|
||||
+MODULE_DEVICE_TABLE(of, ad9834_of_match);
|
||||
+
|
||||
static int ad9834_probe(struct spi_device *spi)
|
||||
{
|
||||
- struct ad9834_platform_data *pdata = dev_get_platdata(&spi->dev);
|
||||
+ const struct of_device_id *of_id = of_match_device(ad9834_of_match,
|
||||
+ &spi->dev);
|
||||
+ struct ad9834_platform_data *pdata;
|
||||
struct ad9834_state *st;
|
||||
struct iio_dev *indio_dev;
|
||||
struct regulator *reg;
|
||||
+ struct clk *clk = NULL;
|
||||
int ret;
|
||||
|
||||
+ if (!pdata && spi->dev.of_node) {
|
||||
+ pdata = ad9834_parse_dt(spi);
|
||||
+ if (IS_ERR(pdata))
|
||||
+ return PTR_ERR(pdata);
|
||||
+ } else {
|
||||
+ pdata = spi->dev.platform_data;
|
||||
+ }
|
||||
+
|
||||
if (!pdata) {
|
||||
dev_dbg(&spi->dev, "no platform data?\n");
|
||||
return -ENODEV;
|
||||
@@ -346,9 +416,30 @@ static int ad9834_probe(struct spi_device *spi)
|
||||
}
|
||||
spi_set_drvdata(spi, indio_dev);
|
||||
st = iio_priv(indio_dev);
|
||||
- st->mclk = pdata->mclk;
|
||||
+
|
||||
+ if (!pdata->mclk) {
|
||||
+ clk = devm_clk_get(&spi->dev, NULL);
|
||||
+ if (IS_ERR(clk))
|
||||
+ return -EPROBE_DEFER;
|
||||
+
|
||||
+ ret = clk_prepare_enable(clk);
|
||||
+ if (ret < 0)
|
||||
+ return ret;
|
||||
+ }
|
||||
+
|
||||
+ if (clk) {
|
||||
+ st->clk = clk;
|
||||
+ st->mclk = clk_get_rate(clk);
|
||||
+ } else {
|
||||
+ st->mclk = pdata->mclk;
|
||||
+ }
|
||||
+
|
||||
+ if (of_id)
|
||||
+ st->devid = (enum ad9834_supported_device_ids)of_id->data;
|
||||
+ else
|
||||
+ st->devid = spi_get_device_id(spi)->driver_data;
|
||||
+
|
||||
st->spi = spi;
|
||||
- st->devid = spi_get_device_id(spi)->driver_data;
|
||||
st->reg = reg;
|
||||
indio_dev->dev.parent = &spi->dev;
|
||||
indio_dev->name = spi_get_device_id(spi)->name;
|
||||
@@ -421,6 +512,9 @@ static int ad9834_probe(struct spi_device *spi)
|
||||
error_disable_reg:
|
||||
regulator_disable(reg);
|
||||
|
||||
+if (clk)
|
||||
+ clk_disable_unprepare(clk);
|
||||
+
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -431,6 +525,8 @@ static int ad9834_remove(struct spi_device *spi)
|
||||
|
||||
iio_device_unregister(indio_dev);
|
||||
regulator_disable(st->reg);
|
||||
+if (st->clk)
|
||||
+ clk_disable_unprepare(st->clk);
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -447,6 +543,7 @@ MODULE_DEVICE_TABLE(spi, ad9834_id);
|
||||
static struct spi_driver ad9834_driver = {
|
||||
.driver = {
|
||||
.name = "ad9834",
|
||||
+ .of_match_table = of_match_ptr(ad9834_of_match),
|
||||
},
|
||||
.probe = ad9834_probe,
|
||||
.remove = ad9834_remove,
|
||||
diff --git a/drivers/staging/iio/frequency/ad9834.h b/drivers/staging/iio/frequency/ad9834.h
|
||||
index 40fdd5da..fd9cccf3 100644
|
||||
--- a/drivers/staging/iio/frequency/ad9834.h
|
||||
+++ b/drivers/staging/iio/frequency/ad9834.h
|
||||
@@ -53,6 +53,7 @@
|
||||
struct ad9834_state {
|
||||
struct spi_device *spi;
|
||||
struct regulator *reg;
|
||||
+ struct clk *clk;
|
||||
unsigned int mclk;
|
||||
unsigned short control;
|
||||
unsigned short devid;
|
||||
@ -56,8 +56,7 @@ if [[ ! -x /lib/modules/$(uname -r)/build/scripts/dtc/dtc ]]; then
|
||||
fi
|
||||
|
||||
if [[ ! -d /boot/overlay-user ]]; then
|
||||
echo >&2 "Please create the directory /boot/overlay-user/"
|
||||
exit -1
|
||||
mkdir -p /boot/overlay-user
|
||||
fi
|
||||
|
||||
temp_dir=$(mktemp -d)
|
||||
|
||||
Loading…
Reference in New Issue
Block a user