ODROID-COMMON:Spicc driver pinctrl for odroid

Change-Id: I0560900a68861592d1717b5421ef0b8324fcbc76
This commit is contained in:
Kevin Kim
2019-01-04 17:20:01 +09:00
committed by Chris KIM
parent 2a4dd34232
commit 740b4e251c
4 changed files with 55 additions and 2 deletions

View File

@@ -611,9 +611,9 @@
SPI0_CLK(GPIOX.11->23 Pin)
SPI_CE0(GPIOX.2->22 Pin), SPI_CE1(GPIOX.10->24 Pin)
*/
pinctrl-names = "default";
pinctrl-names = "default","gpio_periphs";
pinctrl-0 = <&spicc0_pins_x>;
pinctrl-1 = <&spicc0_to_gpiox>;
num_chipselect = <2>;
cs-gpios = <&gpio GPIOX_10 GPIO_ACTIVE_LOW>,

View File

@@ -550,6 +550,15 @@
function = "gpio_periphs";
};
};
spicc0_to_gpiox: spicc0_gpiox {
mux {
groups = "GPIOX_8",
"GPIOX_9",
//"GPIOX_10",
"GPIOX_11";
function = "gpio_periphs";
};
};
}; /* end of pinctrl_periphs */
&gpio_intc {

View File

@@ -253,4 +253,18 @@
function = "gpio_periphs";
};
};
spicc0_pins_x: spicc0_pins_x {
mux {
drive-strength = <3>;
};
};
spicc0_to_gpiox: spicc0_gpiox {
mux {
groups = "GPIOX_8",
"GPIOX_9",
//"GPIOX_10",
"GPIOX_11";
function = "gpio_periphs";
};
};
}; /* end of pinctrl_periphs */

View File

@@ -23,6 +23,10 @@
#include <linux/reset.h>
#include <linux/gpio.h>
#include <linux/dma-mapping.h>
#include <linux/delay.h>
#if defined(CONFIG_ARCH_MESON64_ODROID_COMMON)
#include <linux/pinctrl/consumer.h>
#endif
/*
* The Meson SPICC controller could support DMA based transfers, but is not
@@ -214,6 +218,9 @@ struct meson_spicc_device {
unsigned long rxb_remain;
unsigned long xfer_remain;
bool using_dma;
#if defined(CONFIG_ARCH_MESON64_ODROID_COMMON)
struct pinctrl *pinctrl;
#endif
#ifdef MESON_SPICC_TEST_ENTRY
struct class cls;
u8 test_data;
@@ -1041,6 +1048,9 @@ static int meson_spicc_probe(struct platform_device *pdev)
spicc = spi_master_get_devdata(master);
spicc->master = master;
#if defined(CONFIG_ARCH_MESON64_ODROID_COMMON)
spicc->pinctrl = NULL;
#endif
spicc->pdev = pdev;
platform_set_drvdata(pdev, spicc);
@@ -1076,6 +1086,14 @@ static int meson_spicc_probe(struct platform_device *pdev)
goto out_master;
}
#if defined(CONFIG_ARCH_MESON64_ODROID_COMMON)
spicc->pinctrl = devm_pinctrl_get_select(&pdev->dev, "default");
if (IS_ERR(spicc->pinctrl)) {
spicc->pinctrl = NULL;
dev_err(&pdev->dev, "spi pinmux : can't get spicc_pins\n");
}
#endif
device_reset_optional(&pdev->dev);
master->num_chipselect = 4;
@@ -1112,6 +1130,18 @@ static int meson_spicc_remove(struct platform_device *pdev)
{
struct meson_spicc_device *spicc = platform_get_drvdata(pdev);
#ifdef MESON_SPICC_TEST_ENTRY
class_unregister(&spicc->cls);
#endif /* end MESON_SPICC_TEST_ENTRY */
#if defined(CONFIG_ARCH_MESON64_ODROID_COMMON)
if (spicc->pinctrl)
devm_pinctrl_put(spicc->pinctrl);
spicc->pinctrl = devm_pinctrl_get_select(&pdev->dev, "gpio_periphs");
devm_pinctrl_put(spicc->pinctrl);
spicc->pinctrl = NULL;
#endif
/* Disable SPI */
writel(0, spicc->base + SPICC_CONREG);