From 8356e607a57d86d8766b7cb1e55d95c2a9c2bd03 Mon Sep 17 00:00:00 2001 From: Sunny Luo Date: Wed, 25 Apr 2018 11:26:03 +0800 Subject: [PATCH] spicc: change txlx dts to use amlogic driver. PD#164701: spicc: change txlx dts to use amlogic driver. 1. disable upstream dt and add amlogic dt on r311. 1. fix dirspi interface error for ldim. Change-Id: Ia610cbb69ba03aea63fae8adbeb76579c0250de1 Signed-off-by: Sunny Luo --- arch/arm64/boot/dts/amlogic/mesontxlx.dtsi | 17 +++++++++++++++++ arch/arm64/boot/dts/amlogic/txlx_t962x_r311_1g.dts | 8 ++++++++ arch/arm64/boot/dts/amlogic/txlx_t962x_r311_2g.dts | 8 ++++++++ arch/arm64/boot/dts/amlogic/txlx_t962x_r311_720p.dts | 8 ++++++++ drivers/amlogic/spicc/spicc.c | 18 +++++++++++++++++- 5 files changed, 58 insertions(+), 1 deletion(-) diff --git a/arch/arm64/boot/dts/amlogic/mesontxlx.dtsi b/arch/arm64/boot/dts/amlogic/mesontxlx.dtsi index 5fe22b9..ed0b3ed 100644 --- a/arch/arm64/boot/dts/amlogic/mesontxlx.dtsi +++ b/arch/arm64/boot/dts/amlogic/mesontxlx.dtsi @@ -657,6 +657,23 @@ status = "disabled"; }; + spicc0: spicc0 { + compatible = "amlogic, spicc"; + reg = <0x0 0x13000 0x0 0x40>; + clock-names = "spicc_clk"; + clocks = <&clkc CLKID_SPICC0>; + device_id = <0>; + enhance = <1>; + ssctl = <0>; + dma_tx_threshold = <3>; + dma_num_per_read_burst = <13>; + dma_auto_param = <1>; + delay_control = <0x15>; + #address-cells = <1>; + #size-cells = <0>; + status = "disabled"; + }; + spicc_a: spi@13000 { compatible = "amlogic,meson-txlx-spicc"; reg = <0x0 0x13000 0x0 0x3c>; diff --git a/arch/arm64/boot/dts/amlogic/txlx_t962x_r311_1g.dts b/arch/arm64/boot/dts/amlogic/txlx_t962x_r311_1g.dts index 5e651db..f50089f 100644 --- a/arch/arm64/boot/dts/amlogic/txlx_t962x_r311_1g.dts +++ b/arch/arm64/boot/dts/amlogic/txlx_t962x_r311_1g.dts @@ -1496,8 +1496,16 @@ &spicc_a { + status = "disabled"; + pinctrl-names = "default"; + pinctrl-0 = <&spi_a_pins>; + cs-gpios = <&gpio GPIOZ_3 0>; +}; + +&spicc0 { status = "okay"; pinctrl-names = "default"; pinctrl-0 = <&spi_a_pins>; cs-gpios = <&gpio GPIOZ_3 0>; + num_chipselect = <1>; }; diff --git a/arch/arm64/boot/dts/amlogic/txlx_t962x_r311_2g.dts b/arch/arm64/boot/dts/amlogic/txlx_t962x_r311_2g.dts index c9a8171..c6d7540 100644 --- a/arch/arm64/boot/dts/amlogic/txlx_t962x_r311_2g.dts +++ b/arch/arm64/boot/dts/amlogic/txlx_t962x_r311_2g.dts @@ -1523,8 +1523,16 @@ &spicc_a { + status = "disabled"; + pinctrl-names = "default"; + pinctrl-0 = <&spi_a_pins>; + cs-gpios = <&gpio GPIOZ_3 0>; +}; + +&spicc0 { status = "okay"; pinctrl-names = "default"; pinctrl-0 = <&spi_a_pins>; cs-gpios = <&gpio GPIOZ_3 0>; + num_chipselect = <1>; }; diff --git a/arch/arm64/boot/dts/amlogic/txlx_t962x_r311_720p.dts b/arch/arm64/boot/dts/amlogic/txlx_t962x_r311_720p.dts index 557e0bf..0b939d1 100644 --- a/arch/arm64/boot/dts/amlogic/txlx_t962x_r311_720p.dts +++ b/arch/arm64/boot/dts/amlogic/txlx_t962x_r311_720p.dts @@ -1496,8 +1496,16 @@ &spicc_a { + status = "disabled"; + pinctrl-names = "default"; + pinctrl-0 = <&spi_a_pins>; + cs-gpios = <&gpio GPIOZ_3 0>; +}; + +&spicc0 { status = "okay"; pinctrl-names = "default"; pinctrl-0 = <&spi_a_pins>; cs-gpios = <&gpio GPIOZ_3 0>; + num_chipselect = <1>; }; diff --git a/drivers/amlogic/spicc/spicc.c b/drivers/amlogic/spicc/spicc.c index e4b6150..526275c 100644 --- a/drivers/amlogic/spicc/spicc.c +++ b/drivers/amlogic/spicc/spicc.c @@ -283,6 +283,12 @@ static inline void spicc_set_flag( spicc->flags &= ~(1<regs, MAIN_CLK_AO, on); +} + static inline void spicc_set_bit_width(struct spicc *spicc, u8 bw) { setb(spicc->regs, CON_BITS_PER_WORD, bw-1); @@ -305,6 +311,7 @@ static void spicc_set_mode(struct spicc *spicc, u8 mode) if (mode == spicc->mode) return; + spicc_main_clk_ao(spicc, 1); spicc->mode = mode; if (!spicc_get_flag(spicc, FLAG_ENHANCE)) { if (cpol && !IS_ERR_OR_NULL(spicc->pullup)) @@ -312,9 +319,12 @@ static void spicc_set_mode(struct spicc *spicc, u8 mode) else if (!cpol && !IS_ERR_OR_NULL(spicc->pulldown)) pinctrl_select_state(spicc->pinctrl, spicc->pulldown); } + + setb(spicc->regs, CON_CLK_PHA, cpha); setb(spicc->regs, CON_CLK_POL, cpol); setb(spicc->regs, LOOPBACK_EN, !!(mode & SPI_LOOP)); + spicc_main_clk_ao(spicc, 0); } static void spicc_set_clk(struct spicc *spicc, int speed) @@ -564,6 +574,7 @@ static int spicc_dma_xfer(struct spicc *spicc, struct spi_transfer *t) spicc_reset_fifo(spicc); setb(mem_base, CON_XCH, 0); setb(mem_base, WAIT_CYCLES, spicc->speed >> 25); + spicc->remain = t->len / spicc->bytes_per_word; if (t->tx_dma != INVALID_DMA_ADDRESS) writel(t->tx_dma, mem_base + SPICC_REG_DRADDR); if (t->rx_dma != INVALID_DMA_ADDRESS) @@ -609,6 +620,7 @@ static int spicc_hw_xfer(struct spicc *spicc, u8 *txp, u8 *rxp, int len) setb(mem_base, WAIT_CYCLES, 0); spicc->txp = txp; spicc->rxp = rxp; + spicc->remain = len / spicc->bytes_per_word; spicc_log(spicc, &spicc->remain, 1, PIO_BEGIN); if (spicc->irq) { setb(mem_base, INT_XFER_COM_EN, 1); @@ -726,6 +738,11 @@ static int spicc_setup(struct spi_device *spi) spi->chip_select, spi->cs_gpio, spi->mode, spi->max_speed_hz); spicc_chip_select(spi, 0); + spicc_set_bit_width(spicc, + spi->bits_per_word ? : SPICC_DEFAULT_BIT_WIDTH); + spicc_set_clk(spicc, + spi->max_speed_hz ? : SPICC_DEFAULT_SPEED_HZ); + spicc_set_mode(spicc, spi->mode); return 0; } @@ -765,7 +782,6 @@ static void spicc_handle_one_msg(struct spicc *spicc, struct spi_message *m) if (t->delay_usecs >> 10) udelay(t->delay_usecs >> 10); - spicc->remain = t->len / spicc->bytes_per_word; spicc_set_flag(spicc, FLAG_DMA_EN, 0); if (t->bits_per_word == 64) { spicc_set_flag(spicc, FLAG_DMA_EN, 1); -- 2.7.4