]> asedeno.scripts.mit.edu Git - linux.git/commitdiff
iio: adc: aspeed: Deassert reset in probe
authorJoel Stanley <joel@jms.id.au>
Tue, 31 Oct 2017 02:12:03 +0000 (12:42 +1030)
committerJonathan Cameron <Jonathan.Cameron@huawei.com>
Sat, 2 Dec 2017 10:41:15 +0000 (10:41 +0000)
The ASPEED SoC must deassert a reset in order to use the ADC peripheral.

The device tree bindings are updated to document the resets phandle, and
the example is updated to match what is expected for both the reset and
clock phandle. Note that the bindings should have always had the reset
controller, as the hardware is unusable without it.

Signed-off-by: Joel Stanley <joel@jms.id.au>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Documentation/devicetree/bindings/iio/adc/aspeed_adc.txt
drivers/iio/adc/aspeed_adc.c

index 674e133b7cd7d72aeb81efb4f7cb304ce0204644..034fc2ba100e7924dfafcc93ffbb0ed66a5c1609 100644 (file)
@@ -8,6 +8,7 @@ Required properties:
 - reg: memory window mapping address and length
 - clocks: Input clock used to derive the sample clock. Expected to be the
           SoC's APB clock.
+- resets: Reset controller phandle
 - #io-channel-cells: Must be set to <1> to indicate channels are selected
                      by index.
 
@@ -15,6 +16,7 @@ Example:
        adc@1e6e9000 {
                compatible = "aspeed,ast2400-adc";
                reg = <0x1e6e9000 0xb0>;
-               clocks = <&clk_apb>;
+               clocks = <&syscon ASPEED_CLK_APB>;
+               resets = <&syscon ASPEED_RESET_ADC>;
                #io-channel-cells = <1>;
        };
index 8a958d5f1905cf0d4b98ffbe1e0db0f27ac6df18..327a49ba19916e1405c41980ef7677f5bf7a8bdb 100644 (file)
@@ -17,6 +17,7 @@
 #include <linux/module.h>
 #include <linux/of_platform.h>
 #include <linux/platform_device.h>
+#include <linux/reset.h>
 #include <linux/spinlock.h>
 #include <linux/types.h>
 
@@ -53,11 +54,12 @@ struct aspeed_adc_model_data {
 };
 
 struct aspeed_adc_data {
-       struct device   *dev;
-       void __iomem    *base;
-       spinlock_t      clk_lock;
-       struct clk_hw   *clk_prescaler;
-       struct clk_hw   *clk_scaler;
+       struct device           *dev;
+       void __iomem            *base;
+       spinlock_t              clk_lock;
+       struct clk_hw           *clk_prescaler;
+       struct clk_hw           *clk_scaler;
+       struct reset_control    *rst;
 };
 
 #define ASPEED_CHAN(_idx, _data_reg_addr) {                    \
@@ -217,6 +219,15 @@ static int aspeed_adc_probe(struct platform_device *pdev)
                goto scaler_error;
        }
 
+       data->rst = devm_reset_control_get_exclusive(&pdev->dev, NULL);
+       if (IS_ERR(data->rst)) {
+               dev_err(&pdev->dev,
+                       "invalid or missing reset controller device tree entry");
+               ret = PTR_ERR(data->rst);
+               goto reset_error;
+       }
+       reset_control_deassert(data->rst);
+
        model_data = of_device_get_match_data(&pdev->dev);
 
        if (model_data->wait_init_sequence) {
@@ -263,9 +274,10 @@ static int aspeed_adc_probe(struct platform_device *pdev)
        writel(ASPEED_OPERATION_MODE_POWER_DOWN,
                data->base + ASPEED_REG_ENGINE_CONTROL);
        clk_disable_unprepare(data->clk_scaler->clk);
+reset_error:
+       reset_control_assert(data->rst);
 clk_enable_error:
        clk_hw_unregister_divider(data->clk_scaler);
-
 scaler_error:
        clk_hw_unregister_divider(data->clk_prescaler);
        return ret;
@@ -280,6 +292,7 @@ static int aspeed_adc_remove(struct platform_device *pdev)
        writel(ASPEED_OPERATION_MODE_POWER_DOWN,
                data->base + ASPEED_REG_ENGINE_CONTROL);
        clk_disable_unprepare(data->clk_scaler->clk);
+       reset_control_assert(data->rst);
        clk_hw_unregister_divider(data->clk_scaler);
        clk_hw_unregister_divider(data->clk_prescaler);