All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/3] rockchip: rk3328: Add SPI support
@ 2020-07-08 21:57 Johannes Krottmayer
  2020-07-08 21:57 ` [PATCH 1/3] drivers: clk: rockchip: clk_rk3328: " Johannes Krottmayer
                   ` (3 more replies)
  0 siblings, 4 replies; 8+ messages in thread
From: Johannes Krottmayer @ 2020-07-08 21:57 UTC (permalink / raw)
  To: u-boot

This patch series adds support for the RK3328 SPI
controller.

Johannes Krottmayer (3):
  drivers: clk: rockchip: clk_rk3328: Add SPI support
  drivers: spi: rk_spi: Add support for RK3328
  ARM: dts: rk3328: Add SPI support

 arch/arm/dts/rk3328-u-boot.dtsi   |  5 +++++
 drivers/clk/rockchip/clk_rk3328.c | 31 +++++++++++++++++++++++++++++++
 drivers/spi/rk_spi.c              |  2 ++
 3 files changed, 38 insertions(+)

-- 
2.26.2

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [PATCH 1/3] drivers: clk: rockchip: clk_rk3328: Add SPI support
  2020-07-08 21:57 [PATCH 0/3] rockchip: rk3328: Add SPI support Johannes Krottmayer
@ 2020-07-08 21:57 ` Johannes Krottmayer
  2020-07-18  3:06   ` Kever Yang
  2020-07-08 21:57 ` [PATCH 2/3] drivers: spi: rk_spi: Add support for RK3328 Johannes Krottmayer
                   ` (2 subsequent siblings)
  3 siblings, 1 reply; 8+ messages in thread
From: Johannes Krottmayer @ 2020-07-08 21:57 UTC (permalink / raw)
  To: u-boot

Add SPI support for the RK3328 clock driver

Signed-off-by: Johannes Krottmayer <krjdev@gmail.com>
Cc: Kever Yang <kever.yang@rock-chips.com>
Cc: Jagan Teki <jagan@amarulasolutions.com>
---
 drivers/clk/rockchip/clk_rk3328.c | 31 +++++++++++++++++++++++++++++++
 1 file changed, 31 insertions(+)

diff --git a/drivers/clk/rockchip/clk_rk3328.c b/drivers/clk/rockchip/clk_rk3328.c
index 02d3b08efa..bf4f1069ea 100644
--- a/drivers/clk/rockchip/clk_rk3328.c
+++ b/drivers/clk/rockchip/clk_rk3328.c
@@ -555,6 +555,31 @@ static ulong rk3328_saradc_set_clk(struct rk3328_cru *cru, uint hz)
 	return rk3328_saradc_get_clk(cru);
 }
 
+static ulong rk3328_spi_get_clk(struct rk3328_cru *cru)
+{
+	u32 div, val;
+
+	val = readl(&cru->clksel_con[24]);
+	div = (val & CLK_SPI_DIV_CON_MASK) >> CLK_SPI_DIV_CON_SHIFT;
+
+	return DIV_TO_RATE(OSC_HZ, div);
+}
+
+static ulong rk3328_spi_set_clk(struct rk3328_cru *cru, uint hz)
+{
+	u32 src_clk_div;
+
+	src_clk_div = GPLL_HZ / hz;
+	assert(src_clk_div < 128);
+
+	rk_clrsetreg(&cru->clksel_con[24],
+		     CLK_PWM_PLL_SEL_MASK | CLK_PWM_DIV_CON_MASK,
+		     CLK_PWM_PLL_SEL_GPLL << CLK_PWM_PLL_SEL_SHIFT |
+		     (src_clk_div - 1) << CLK_PWM_DIV_CON_SHIFT);
+
+	return rk3328_spi_get_clk(cru);
+}
+
 static ulong rk3328_clk_get_rate(struct clk *clk)
 {
 	struct rk3328_clk_priv *priv = dev_get_priv(clk->dev);
@@ -581,6 +606,9 @@ static ulong rk3328_clk_get_rate(struct clk *clk)
 	case SCLK_SARADC:
 		rate = rk3328_saradc_get_clk(priv->cru);
 		break;
+	case SCLK_SPI:
+		rate = rk3328_spi_get_clk(priv->cru);
+		break;
 	default:
 		return -ENOENT;
 	}
@@ -617,6 +645,9 @@ static ulong rk3328_clk_set_rate(struct clk *clk, ulong rate)
 	case SCLK_SARADC:
 		ret = rk3328_saradc_set_clk(priv->cru, rate);
 		break;
+	case SCLK_SPI:
+		ret = rk3328_spi_set_clk(priv->cru, rate);
+		break;
 	case DCLK_LCDC:
 	case SCLK_PDM:
 	case SCLK_RTC32K:
-- 
2.26.2

^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [PATCH 2/3] drivers: spi: rk_spi: Add support for RK3328
  2020-07-08 21:57 [PATCH 0/3] rockchip: rk3328: Add SPI support Johannes Krottmayer
  2020-07-08 21:57 ` [PATCH 1/3] drivers: clk: rockchip: clk_rk3328: " Johannes Krottmayer
@ 2020-07-08 21:57 ` Johannes Krottmayer
  2020-07-18  3:06   ` Kever Yang
  2020-07-08 21:57 ` [PATCH 3/3] ARM: dts: rk3328: Add SPI support Johannes Krottmayer
  2020-07-18 14:28 ` [PATCH 0/3] rockchip: " Kever Yang
  3 siblings, 1 reply; 8+ messages in thread
From: Johannes Krottmayer @ 2020-07-08 21:57 UTC (permalink / raw)
  To: u-boot

Add support for the RK3328 SPI controller

Signed-off-by: Johannes Krottmayer <krjdev@gmail.com>
Cc: Kever Yang <kever.yang@rock-chips.com>
Cc: Jagan Teki <jagan@amarulasolutions.com>
---
I don't know if "rk3399_spi_params" is also required for the
RK3328 SPI controller.

Probing, Reading, Writing and Erasing of a flash device works
with the SF command. Tested it with the PINE64 Rock64 board.

 drivers/spi/rk_spi.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/spi/rk_spi.c b/drivers/spi/rk_spi.c
index 833cb04922..0495e04945 100644
--- a/drivers/spi/rk_spi.c
+++ b/drivers/spi/rk_spi.c
@@ -545,7 +545,9 @@ const  struct rockchip_spi_params rk3399_spi_params = {
 };
 
 static const struct udevice_id rockchip_spi_ids[] = {
+	{ .compatible = "rockchip,rk3066-spi" },
 	{ .compatible = "rockchip,rk3288-spi" },
+	{ .compatible = "rockchip,rk3328-spi" },
 	{ .compatible = "rockchip,rk3368-spi",
 	  .data = (ulong)&rk3399_spi_params },
 	{ .compatible = "rockchip,rk3399-spi",
-- 
2.26.2

^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [PATCH 3/3] ARM: dts: rk3328: Add SPI support
  2020-07-08 21:57 [PATCH 0/3] rockchip: rk3328: Add SPI support Johannes Krottmayer
  2020-07-08 21:57 ` [PATCH 1/3] drivers: clk: rockchip: clk_rk3328: " Johannes Krottmayer
  2020-07-08 21:57 ` [PATCH 2/3] drivers: spi: rk_spi: Add support for RK3328 Johannes Krottmayer
@ 2020-07-08 21:57 ` Johannes Krottmayer
  2020-07-18  3:06   ` Kever Yang
  2020-07-18 14:28 ` [PATCH 0/3] rockchip: " Kever Yang
  3 siblings, 1 reply; 8+ messages in thread
From: Johannes Krottmayer @ 2020-07-08 21:57 UTC (permalink / raw)
  To: u-boot

Add U-Boot SPI support for the RK3328

Signed-off-by: Johannes Krottmayer <krjdev@gmail.com>
Cc: Kever Yang <kever.yang@rock-chips.com>
Cc: Jagan Teki <jagan@amarulasolutions.com>
---
 arch/arm/dts/rk3328-u-boot.dtsi | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/arch/arm/dts/rk3328-u-boot.dtsi b/arch/arm/dts/rk3328-u-boot.dtsi
index c69e13e11e..c980daae99 100644
--- a/arch/arm/dts/rk3328-u-boot.dtsi
+++ b/arch/arm/dts/rk3328-u-boot.dtsi
@@ -7,6 +7,7 @@
 	aliases {
 		mmc0 = &emmc;
 		mmc1 = &sdmmc;
+ 		spi0 = &spi0;
 	};
 
 	chosen {
@@ -66,3 +67,7 @@
 &usb20_otg {
 	hnp-srp-disable;
 };
+
+&spi0 {
+	u-boot,dm-pre-reloc;
+};
-- 
2.26.2

^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [PATCH 1/3] drivers: clk: rockchip: clk_rk3328: Add SPI support
  2020-07-08 21:57 ` [PATCH 1/3] drivers: clk: rockchip: clk_rk3328: " Johannes Krottmayer
@ 2020-07-18  3:06   ` Kever Yang
  0 siblings, 0 replies; 8+ messages in thread
From: Kever Yang @ 2020-07-18  3:06 UTC (permalink / raw)
  To: u-boot


On 2020/7/9 ??5:57, Johannes Krottmayer wrote:
> Add SPI support for the RK3328 clock driver
>
> Signed-off-by: Johannes Krottmayer <krjdev@gmail.com>
> Cc: Kever Yang <kever.yang@rock-chips.com>
> Cc: Jagan Teki <jagan@amarulasolutions.com>
Reviewed-by: Kever Yang<kever.yang@rock-chips.com>

Thanks,
- Kever
> ---
>   drivers/clk/rockchip/clk_rk3328.c | 31 +++++++++++++++++++++++++++++++
>   1 file changed, 31 insertions(+)
>
> diff --git a/drivers/clk/rockchip/clk_rk3328.c b/drivers/clk/rockchip/clk_rk3328.c
> index 02d3b08efa..bf4f1069ea 100644
> --- a/drivers/clk/rockchip/clk_rk3328.c
> +++ b/drivers/clk/rockchip/clk_rk3328.c
> @@ -555,6 +555,31 @@ static ulong rk3328_saradc_set_clk(struct rk3328_cru *cru, uint hz)
>   	return rk3328_saradc_get_clk(cru);
>   }
>   
> +static ulong rk3328_spi_get_clk(struct rk3328_cru *cru)
> +{
> +	u32 div, val;
> +
> +	val = readl(&cru->clksel_con[24]);
> +	div = (val & CLK_SPI_DIV_CON_MASK) >> CLK_SPI_DIV_CON_SHIFT;
> +
> +	return DIV_TO_RATE(OSC_HZ, div);
> +}
> +
> +static ulong rk3328_spi_set_clk(struct rk3328_cru *cru, uint hz)
> +{
> +	u32 src_clk_div;
> +
> +	src_clk_div = GPLL_HZ / hz;
> +	assert(src_clk_div < 128);
> +
> +	rk_clrsetreg(&cru->clksel_con[24],
> +		     CLK_PWM_PLL_SEL_MASK | CLK_PWM_DIV_CON_MASK,
> +		     CLK_PWM_PLL_SEL_GPLL << CLK_PWM_PLL_SEL_SHIFT |
> +		     (src_clk_div - 1) << CLK_PWM_DIV_CON_SHIFT);
> +
> +	return rk3328_spi_get_clk(cru);
> +}
> +
>   static ulong rk3328_clk_get_rate(struct clk *clk)
>   {
>   	struct rk3328_clk_priv *priv = dev_get_priv(clk->dev);
> @@ -581,6 +606,9 @@ static ulong rk3328_clk_get_rate(struct clk *clk)
>   	case SCLK_SARADC:
>   		rate = rk3328_saradc_get_clk(priv->cru);
>   		break;
> +	case SCLK_SPI:
> +		rate = rk3328_spi_get_clk(priv->cru);
> +		break;
>   	default:
>   		return -ENOENT;
>   	}
> @@ -617,6 +645,9 @@ static ulong rk3328_clk_set_rate(struct clk *clk, ulong rate)
>   	case SCLK_SARADC:
>   		ret = rk3328_saradc_set_clk(priv->cru, rate);
>   		break;
> +	case SCLK_SPI:
> +		ret = rk3328_spi_set_clk(priv->cru, rate);
> +		break;
>   	case DCLK_LCDC:
>   	case SCLK_PDM:
>   	case SCLK_RTC32K:

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [PATCH 2/3] drivers: spi: rk_spi: Add support for RK3328
  2020-07-08 21:57 ` [PATCH 2/3] drivers: spi: rk_spi: Add support for RK3328 Johannes Krottmayer
@ 2020-07-18  3:06   ` Kever Yang
  0 siblings, 0 replies; 8+ messages in thread
From: Kever Yang @ 2020-07-18  3:06 UTC (permalink / raw)
  To: u-boot


On 2020/7/9 ??5:57, Johannes Krottmayer wrote:
> Add support for the RK3328 SPI controller
>
> Signed-off-by: Johannes Krottmayer <krjdev@gmail.com>
> Cc: Kever Yang <kever.yang@rock-chips.com>
> Cc: Jagan Teki <jagan@amarulasolutions.com>
Reviewed-by: Kever Yang<kever.yang@rock-chips.com>

Thanks,
- Kever
> ---
> I don't know if "rk3399_spi_params" is also required for the
> RK3328 SPI controller.
>
> Probing, Reading, Writing and Erasing of a flash device works
> with the SF command. Tested it with the PINE64 Rock64 board.
>
>   drivers/spi/rk_spi.c | 2 ++
>   1 file changed, 2 insertions(+)
>
> diff --git a/drivers/spi/rk_spi.c b/drivers/spi/rk_spi.c
> index 833cb04922..0495e04945 100644
> --- a/drivers/spi/rk_spi.c
> +++ b/drivers/spi/rk_spi.c
> @@ -545,7 +545,9 @@ const  struct rockchip_spi_params rk3399_spi_params = {
>   };
>   
>   static const struct udevice_id rockchip_spi_ids[] = {
> +	{ .compatible = "rockchip,rk3066-spi" },
>   	{ .compatible = "rockchip,rk3288-spi" },
> +	{ .compatible = "rockchip,rk3328-spi" },
>   	{ .compatible = "rockchip,rk3368-spi",
>   	  .data = (ulong)&rk3399_spi_params },
>   	{ .compatible = "rockchip,rk3399-spi",

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [PATCH 3/3] ARM: dts: rk3328: Add SPI support
  2020-07-08 21:57 ` [PATCH 3/3] ARM: dts: rk3328: Add SPI support Johannes Krottmayer
@ 2020-07-18  3:06   ` Kever Yang
  0 siblings, 0 replies; 8+ messages in thread
From: Kever Yang @ 2020-07-18  3:06 UTC (permalink / raw)
  To: u-boot


On 2020/7/9 ??5:57, Johannes Krottmayer wrote:
> Add U-Boot SPI support for the RK3328
>
> Signed-off-by: Johannes Krottmayer <krjdev@gmail.com>
> Cc: Kever Yang <kever.yang@rock-chips.com>
> Cc: Jagan Teki <jagan@amarulasolutions.com>
Reviewed-by: Kever Yang<kever.yang@rock-chips.com>

Thanks,
- Kever
> ---
>   arch/arm/dts/rk3328-u-boot.dtsi | 5 +++++
>   1 file changed, 5 insertions(+)
>
> diff --git a/arch/arm/dts/rk3328-u-boot.dtsi b/arch/arm/dts/rk3328-u-boot.dtsi
> index c69e13e11e..c980daae99 100644
> --- a/arch/arm/dts/rk3328-u-boot.dtsi
> +++ b/arch/arm/dts/rk3328-u-boot.dtsi
> @@ -7,6 +7,7 @@
>   	aliases {
>   		mmc0 = &emmc;
>   		mmc1 = &sdmmc;
> + 		spi0 = &spi0;
>   	};
>   
>   	chosen {
> @@ -66,3 +67,7 @@
>   &usb20_otg {
>   	hnp-srp-disable;
>   };
> +
> +&spi0 {
> +	u-boot,dm-pre-reloc;
> +};

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [PATCH 0/3] rockchip: rk3328: Add SPI support
  2020-07-08 21:57 [PATCH 0/3] rockchip: rk3328: Add SPI support Johannes Krottmayer
                   ` (2 preceding siblings ...)
  2020-07-08 21:57 ` [PATCH 3/3] ARM: dts: rk3328: Add SPI support Johannes Krottmayer
@ 2020-07-18 14:28 ` Kever Yang
  3 siblings, 0 replies; 8+ messages in thread
From: Kever Yang @ 2020-07-18 14:28 UTC (permalink / raw)
  To: u-boot


On 2020/7/9 ??5:57, Johannes Krottmayer wrote:
> This patch series adds support for the RK3328 SPI
> controller.
>
> Johannes Krottmayer (3):
>    drivers: clk: rockchip: clk_rk3328: Add SPI support
>    drivers: spi: rk_spi: Add support for RK3328
>    ARM: dts: rk3328: Add SPI support
>
>   arch/arm/dts/rk3328-u-boot.dtsi   |  5 +++++
>   drivers/clk/rockchip/clk_rk3328.c | 31 +++++++++++++++++++++++++++++++
>   drivers/spi/rk_spi.c              |  2 ++
>   3 files changed, 38 insertions(+)
>

Applied to u-boot-rockchip master for this patch set, thanks.

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2020-07-18 14:28 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-07-08 21:57 [PATCH 0/3] rockchip: rk3328: Add SPI support Johannes Krottmayer
2020-07-08 21:57 ` [PATCH 1/3] drivers: clk: rockchip: clk_rk3328: " Johannes Krottmayer
2020-07-18  3:06   ` Kever Yang
2020-07-08 21:57 ` [PATCH 2/3] drivers: spi: rk_spi: Add support for RK3328 Johannes Krottmayer
2020-07-18  3:06   ` Kever Yang
2020-07-08 21:57 ` [PATCH 3/3] ARM: dts: rk3328: Add SPI support Johannes Krottmayer
2020-07-18  3:06   ` Kever Yang
2020-07-18 14:28 ` [PATCH 0/3] rockchip: " Kever Yang

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.