Skip to content

Commit

Permalink
spi/s3c64xx: let device core setup the default pin configuration
Browse files Browse the repository at this point in the history
With device core now able to setup the default pin configuration,
the pin configuration code based on the deprecated Samsung specific
gpio bindings is removed.

Signed-off-by: Thomas Abraham <[email protected]>
Signed-off-by: Doug Anderson <[email protected]>
Acked-by: Linus Walleij <[email protected]>
Reviewed-by: Doug Anderson <[email protected]>
Tested-by: Doug Anderson <[email protected]>
Signed-off-by: Grant Likely <[email protected]>
  • Loading branch information
Thomas Abraham authored and glikely committed Apr 16, 2013
1 parent 1962423 commit 00ab539
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 68 deletions.
8 changes: 2 additions & 6 deletions Documentation/devicetree/bindings/spi/spi-samsung.txt
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,6 @@ Required Board Specific Properties:

- #address-cells: should be 1.
- #size-cells: should be 0.
- gpios: The gpio specifier for clock, mosi and miso interface lines (in the
order specified). The format of the gpio specifier depends on the gpio
controller.

Optional Board Specific Properties:

Expand Down Expand Up @@ -86,9 +83,8 @@ Example:
spi_0: spi@12d20000 {
#address-cells = <1>;
#size-cells = <0>;
gpios = <&gpa2 4 2 3 0>,
<&gpa2 6 2 3 0>,
<&gpa2 7 2 3 0>;
pinctrl-names = "default";
pinctrl-0 = <&spi0_bus>;

w25q80bw@0 {
#address-cells = <1>;
Expand Down
66 changes: 4 additions & 62 deletions drivers/spi/spi-s3c64xx.c
Original file line number Diff line number Diff line change
Expand Up @@ -1148,41 +1148,6 @@ static void s3c64xx_spi_hwinit(struct s3c64xx_spi_driver_data *sdd, int channel)
}

#ifdef CONFIG_OF
static int s3c64xx_spi_parse_dt_gpio(struct s3c64xx_spi_driver_data *sdd)
{
struct device *dev = &sdd->pdev->dev;
int idx, gpio, ret;

/* find gpios for mosi, miso and clock lines */
for (idx = 0; idx < 3; idx++) {
gpio = of_get_gpio(dev->of_node, idx);
if (!gpio_is_valid(gpio)) {
dev_err(dev, "invalid gpio[%d]: %d\n", idx, gpio);
goto free_gpio;
}
sdd->gpios[idx] = gpio;
ret = gpio_request(gpio, "spi-bus");
if (ret) {
dev_err(dev, "gpio [%d] request failed: %d\n",
gpio, ret);
goto free_gpio;
}
}
return 0;

free_gpio:
while (--idx >= 0)
gpio_free(sdd->gpios[idx]);
return -EINVAL;
}

static void s3c64xx_spi_dt_gpio_free(struct s3c64xx_spi_driver_data *sdd)
{
unsigned int idx;
for (idx = 0; idx < 3; idx++)
gpio_free(sdd->gpios[idx]);
}

static struct s3c64xx_spi_info *s3c64xx_spi_parse_dt(struct device *dev)
{
struct s3c64xx_spi_info *sci;
Expand Down Expand Up @@ -1215,15 +1180,6 @@ static struct s3c64xx_spi_info *s3c64xx_spi_parse_dt(struct device *dev)
{
return dev->platform_data;
}

static int s3c64xx_spi_parse_dt_gpio(struct s3c64xx_spi_driver_data *sdd)
{
return -EINVAL;
}

static void s3c64xx_spi_dt_gpio_free(struct s3c64xx_spi_driver_data *sdd)
{
}
#endif

static const struct of_device_id s3c64xx_spi_dt_match[];
Expand Down Expand Up @@ -1344,10 +1300,7 @@ static int s3c64xx_spi_probe(struct platform_device *pdev)
goto err0;
}

if (!sci->cfg_gpio && pdev->dev.of_node) {
if (s3c64xx_spi_parse_dt_gpio(sdd))
return -EBUSY;
} else if (sci->cfg_gpio == NULL || sci->cfg_gpio()) {
if (sci->cfg_gpio && sci->cfg_gpio()) {
dev_err(&pdev->dev, "Unable to config gpio\n");
ret = -EBUSY;
goto err0;
Expand All @@ -1358,13 +1311,13 @@ static int s3c64xx_spi_probe(struct platform_device *pdev)
if (IS_ERR(sdd->clk)) {
dev_err(&pdev->dev, "Unable to acquire clock 'spi'\n");
ret = PTR_ERR(sdd->clk);
goto err1;
goto err0;
}

if (clk_prepare_enable(sdd->clk)) {
dev_err(&pdev->dev, "Couldn't enable clock 'spi'\n");
ret = -EBUSY;
goto err1;
goto err0;
}

sprintf(clk_name, "spi_busclk%d", sci->src_clk_nr);
Expand Down Expand Up @@ -1421,9 +1374,6 @@ static int s3c64xx_spi_probe(struct platform_device *pdev)
clk_disable_unprepare(sdd->src_clk);
err2:
clk_disable_unprepare(sdd->clk);
err1:
if (!sdd->cntrlr_info->cfg_gpio && pdev->dev.of_node)
s3c64xx_spi_dt_gpio_free(sdd);
err0:
platform_set_drvdata(pdev, NULL);
spi_master_put(master);
Expand All @@ -1446,9 +1396,6 @@ static int s3c64xx_spi_remove(struct platform_device *pdev)

clk_disable_unprepare(sdd->clk);

if (!sdd->cntrlr_info->cfg_gpio && pdev->dev.of_node)
s3c64xx_spi_dt_gpio_free(sdd);

platform_set_drvdata(pdev, NULL);
spi_master_put(master);

Expand All @@ -1467,9 +1414,6 @@ static int s3c64xx_spi_suspend(struct device *dev)
clk_disable_unprepare(sdd->src_clk);
clk_disable_unprepare(sdd->clk);

if (!sdd->cntrlr_info->cfg_gpio && dev->of_node)
s3c64xx_spi_dt_gpio_free(sdd);

sdd->cur_speed = 0; /* Output Clock is stopped */

return 0;
Expand All @@ -1481,9 +1425,7 @@ static int s3c64xx_spi_resume(struct device *dev)
struct s3c64xx_spi_driver_data *sdd = spi_master_get_devdata(master);
struct s3c64xx_spi_info *sci = sdd->cntrlr_info;

if (!sci->cfg_gpio && dev->of_node)
s3c64xx_spi_parse_dt_gpio(sdd);
else
if (sci->cfg_gpio)
sci->cfg_gpio();

/* Enable the clock */
Expand Down

0 comments on commit 00ab539

Please sign in to comment.