]> git.sur5r.net Git - u-boot/commitdiff
rockchip: pinctrl: rk3399: add support for the SPI5 controller
authorPhilipp Tomsich <philipp.tomsich@theobroma-systems.com>
Thu, 20 Apr 2017 20:05:53 +0000 (22:05 +0200)
committerSimon Glass <sjg@chromium.org>
Wed, 10 May 2017 19:37:21 +0000 (13:37 -0600)
This commit adds support for the pin-configuration of the SPI5
controller of the RK3399 through the following changes:
 * grf_rk3399.h: adds definition for configuring the SPI5 pins
     in the GPIO2C group
 * periph.h: defines PERIPH_ID_SPI3 through PERIPH_ID_SPI5
 * pinctrl_rk3399.c: adds the reverse-mapping from the IRQ# to
         PERIPH_ID_SPI5; dispatches PERIPH_ID_SPI3
     through SPI5 to the appropriate pin-config
     function; implements the pin-configuration
     for PERIPH_ID_SPI5 using the GPIO2C group

X-AffectedPlatforms: RK3399-Q7
Signed-off-by: Philipp Tomsich <philipp.tomsich@theobroma-systems.com>
Tested-by: Jakob Unterwurzacher <jakob.unterwurzacher@theobroma-systems.com>
Acked-by: Simon Glass <sjg@chromium.org>
arch/arm/include/asm/arch-rockchip/grf_rk3399.h
arch/arm/include/asm/arch-rockchip/periph.h
drivers/pinctrl/rockchip/pinctrl_rk3399.c

index c42475388b49057872591e005f88cdff6f664c4f..cbcff2e4ebc2a97854ee710e1162d974e2911042 100644 (file)
@@ -344,6 +344,18 @@ enum {
        GRF_GPIO2C1_SEL_SHIFT   = 2,
        GRF_GPIO2C1_SEL_MASK    = 3 << GRF_GPIO2C1_SEL_SHIFT,
        GRF_UART0BT_SOUT        = 1,
+       GRF_GPIO2C4_SEL_SHIFT   = 8,
+       GRF_GPIO2C4_SEL_MASK    = 3 << GRF_GPIO2C4_SEL_SHIFT,
+       GRF_SPI5EXPPLUS_RXD     = 2,
+       GRF_GPIO2C5_SEL_SHIFT   = 10,
+       GRF_GPIO2C5_SEL_MASK    = 3 << GRF_GPIO2C5_SEL_SHIFT,
+       GRF_SPI5EXPPLUS_TXD     = 2,
+       GRF_GPIO2C6_SEL_SHIFT   = 12,
+       GRF_GPIO2C6_SEL_MASK    = 3 << GRF_GPIO2C6_SEL_SHIFT,
+       GRF_SPI5EXPPLUS_CLK     = 2,
+       GRF_GPIO2C7_SEL_SHIFT   = 14,
+       GRF_GPIO2C7_SEL_MASK    = 3 << GRF_GPIO2C7_SEL_SHIFT,
+       GRF_SPI5EXPPLUS_CSN0    = 2,
 
        /* GRF_GPIO3A_IOMUX */
        GRF_GPIO3A0_SEL_SHIFT   = 0,
index 239a27443aa47a33e1b1e33bf273ea81d15bc66d..8018d4734847c9361378bd83ce8d9c8241c03e51 100644 (file)
@@ -27,6 +27,9 @@ enum periph_id {
        PERIPH_ID_SPI0,
        PERIPH_ID_SPI1,
        PERIPH_ID_SPI2,
+       PERIPH_ID_SPI3,
+       PERIPH_ID_SPI4,
+       PERIPH_ID_SPI5,
        PERIPH_ID_UART0,
        PERIPH_ID_UART1,
        PERIPH_ID_UART2,
index 507bec4a969c0852149698e66084d0113342c766..6eb657fd5ae0ac9cd88cd6f859f4395478b9146c 100644 (file)
@@ -145,7 +145,19 @@ static int pinctrl_rk3399_spi_config(struct rk3399_grf_regs *grf,
                             | GRF_SPI2TPM_CLK << GRF_GPIO2B3_SEL_SHIFT
                             | GRF_SPI2TPM_CSN0 << GRF_GPIO2B4_SEL_SHIFT);
                break;
+       case PERIPH_ID_SPI5:
+               if (cs != 0)
+                       goto err;
+               rk_clrsetreg(&grf->gpio2c_iomux,
+                            GRF_GPIO2C4_SEL_MASK | GRF_GPIO2C5_SEL_MASK
+                            | GRF_GPIO2C6_SEL_MASK | GRF_GPIO2C7_SEL_MASK,
+                            GRF_SPI5EXPPLUS_RXD << GRF_GPIO2C4_SEL_SHIFT
+                            | GRF_SPI5EXPPLUS_TXD << GRF_GPIO2C5_SEL_SHIFT
+                            | GRF_SPI5EXPPLUS_CLK << GRF_GPIO2C6_SEL_SHIFT
+                            | GRF_SPI5EXPPLUS_CSN0 << GRF_GPIO2C7_SEL_SHIFT);
+               break;
        default:
+               printf("%s: spi_id %d is not supported.\n", __func__, spi_id);
                goto err;
        }
 
@@ -259,6 +271,9 @@ static int rk3399_pinctrl_request(struct udevice *dev, int func, int flags)
        case PERIPH_ID_SPI0:
        case PERIPH_ID_SPI1:
        case PERIPH_ID_SPI2:
+       case PERIPH_ID_SPI3:
+       case PERIPH_ID_SPI4:
+       case PERIPH_ID_SPI5:
                pinctrl_rk3399_spi_config(priv->grf, priv->pmugrf, func, flags);
                break;
        case PERIPH_ID_UART0:
@@ -307,6 +322,8 @@ static int rk3399_pinctrl_get_periph_id(struct udevice *dev,
                return PERIPH_ID_SPI1;
        case 52:
                return PERIPH_ID_SPI2;
+       case 132:
+               return PERIPH_ID_SPI5;
        case 57:
                return PERIPH_ID_I2C0;
        case 59: /* Note strange order */