SPI: spi-pxa2xx: Add support for Intel Quark X1000 SPI controller
Subsystems (3)
PATCH 1/1 SPI: spi-pxa2xx: Add support for Intel Quark X1000 SPI controller
Hi,
Intel Quark X1000 consists of two SPI controllers which can be PCI enumerated. SPI-PXA2XX PCI layer doesn't support it. Thus, we add support for Intel Quark X1000 SPI as well.
Weike Chen (1):
SPI: spi-pxa2xx: SPI support for Intel Quark X1000
drivers/spi/spi-pxa2xx-pci.c | 8 ++ drivers/spi/spi-pxa2xx.c | 251 +++++++++++++++++++++++++++++++++++------- drivers/spi/spi-pxa2xx.h | 8 +- include/linux/pxa2xx_ssp.h | 21 ++++ 4 files changed, 249 insertions(+), 39 deletions(-)
Signature · 1 line
1.7.9.5
PATCH 1/1 SPI: spi-pxa2xx: SPI support for Intel Quark X1000
There are two SPI controllers exported by PCI subsystem for Intel Quark X1000. The SPI memory mapped I/O registers supported by Quark are different from the current implementation, and Quark only supports the registers of 'SSCR0', 'SSCR1', 'SSSR', 'SSDR', and 'DDS_RATE'. This patch is to enable the SPI for Intel Quark X1000.
This piece of work is derived from Dan O'Donovan's initial work for Intel Quark X1000 SPI enabling.
--- drivers/spi/spi-pxa2xx-pci.c | 8 ++ drivers/spi/spi-pxa2xx.c | 251 +++++++++++++++++++++++++++++++++++------- drivers/spi/spi-pxa2xx.h | 8 +- include/linux/pxa2xx_ssp.h | 21 ++++ 4 files changed, 249 insertions(+), 39 deletions(-)
drivers/spi/spi-pxa2xx-pci.c +8 -0
@@ -19,6 +19,7 @@ enum {PORT_BSW0 ,PORT_BSW1 ,PORT_BSW2 , + PORT_QUARK_X1000, }; struct pxa_spi_info {
@@ -92,6 +93,12 @@ static struct pxa_spi_info spi_info_configs[] = { .tx_param = &bsw2_tx_param, .rx_param = &bsw2_rx_param, }, + [PORT_QUARK_X1000] = { + .type = QUARK_X1000_SSP, + .port_id = -1, + .num_chipselect = 4, + .max_clk_rate = 50000000, + }, }; static int pxa2xx_spi_pci_probe(struct pci_dev *dev,
@@ -192,6 +199,7 @@ static void pxa2xx_spi_pci_remove(struct pci_dev *dev)static const struct pci_device_id pxa2xx_spi_pci_devices[] = { {PCI_VDEVICE (INTEL ,0x2e6a ),PORT_CE4100 }, + {PCI_VDEVICE (INTEL ,0x0935 ),PORT_QUARK_X1000 }, {PCI_VDEVICE (INTEL ,0x0f0e ),PORT_BYT }, {PCI_VDEVICE (INTEL ,0x228e ),PORT_BSW0 }, {PCI_VDEVICE (INTEL ,0x2290 ),PORT_BSW1 },
drivers/spi/spi-pxa2xx.c +213 -38
388 lines not on this page · raw message
drivers/spi/spi-pxa2xx.h +7 -1
@@ -93,6 +93,7 @@ struct driver_data {struct chip_data {u32 cr0;u32 cr1; +u32 dds_rate;u32 psp;u32 timeout;u8 n_bytes;
@@ -126,6 +127,7 @@ DEFINE_SSP_REG(SSCR1, 0x04) DEFINE_SSP_REG(SSSR, 0x08) DEFINE_SSP_REG(SSITR, 0x0c) DEFINE_SSP_REG(SSDR, 0x10) +DEFINE_SSP_REG(DDS_RATE, 0x28) /* DDS Clock Rate */ DEFINE_SSP_REG(SSTO, 0x28) DEFINE_SSP_REG(SSPSP, 0x2c)DEFINE_SSP_REG (SSITF ,SSITF )
@@ -145,6 +147,9 @@ static inline int pxa25x_ssp_comp(struct driver_data *drv_data)return 1 ;if (drv_data->ssp_type ==CE4100_SSP )return 1 ; +if (drv_data->ssp_type ==QUARK_X1000_SSP ) +return 1 ; +return 0 ; }
@@ -152,7 +157,8 @@ static inline void write_SSSR_CS(struct driver_data *drv_data, u32 val) {void __iomem *reg = drv_data->ioaddr; -if (drv_data->ssp_type ==CE4100_SSP ) +if (drv_data->ssp_type ==CE4100_SSP || + drv_data->ssp_type ==QUARK_X1000_SSP ) val |=read_SSSR (reg) &SSSR_ALT_FRM_MASK ;write_SSSR (val, reg);
include/linux/pxa2xx_ssp.h +21 -0
@@ -106,6 +106,26 @@#define SSCR1_TxTresh (x) (((x) - 1) << 6)/* level [1..4] */ #define SSCR1_RFT (0x00000c00)/* Receive FIFO Threshold (mask) */ #define SSCR1_RxTresh (x) (((x) - 1) << 10)/* level [1..4] */ + +/* QUARK_X1000 SSCR0 bit definition */ +#define QUARK_X1000_SSCR0_DSS (0x1F)/* Data Size Select (mask) */ +#define QUARK_X1000_SSCR0_DataSize (x) ((x) - 1)/* Data Size Select [4..32] */ +#define QUARK_X1000_SSCR0_FRF (0x3 << 5)/* FRame Format (mask) */ +#define QUARK_X1000_SSCR0_Motorola (0x0 << 5)/* Motorola's Serial Peripheral Interface (SPI) */ + +#define RX_THRESH_QUARK_X1000_DFLT 1 +#define TX_THRESH_QUARK_X1000_DFLT 16 + +#define QUARK_X1000_SSSR_TFL_MASK (0x1F << 8)/* Transmit FIFO Level mask */ +#define QUARK_X1000_SSSR_RFL_MASK (0x1F << 13)/* Receive FIFO Level mask */ + +#define QUARK_X1000_SSCR1_TFT (0x1F << 6)/* Transmit FIFO Threshold (mask) */ +#define QUARK_X1000_SSCR1_TxTresh (x) (((x) - 1) << 6)/* level [1..32] */ +#define QUARK_X1000_SSCR1_RFT (0x1F << 11)/* Receive FIFO Threshold (mask) */ +#define QUARK_X1000_SSCR1_RxTresh (x) (((x) - 1) << 11)/* level [1..32] */ +#define QUARK_X1000_SSCR1_STRF (1 << 17)/* Select FIFO or EFWR */ +#define QUARK_X1000_SSCR1_EFWR (1 << 16)/* Enable FIFO Write/Read */ +#endif /* extra bits in PXA255, PXA26x and PXA27x SSP ports */
@@ -175,6 +195,7 @@ enum pxa_ssp_type {PXA910_SSP ,CE4100_SSP ,LPSS_SSP , + QUARK_X1000_SSP, }; struct ssp_device {
Signature · 1 line
1.7.9.5
Mark Brown
maintainerRe: [PATCH] SPI: spi-pxa2xx: SPI support for Intel Quark X1000
drivers/spi/spi-pxa2xx.c static bool is_lpss_ssp(const struct driver_data *drv_data) · line 144
Quoted 7 lines · Weike Chen
drivers/spi/spi-pxa2xx.c +7
-0+static u32 pxa2xx_spi_get_ssrc1_change_mask (const struct driver_data *drv_data) +{ +if (!is_quark_x1000_ssp (drv_data)) +return SSCR1_CHANGE_MASK ; + +return QUARK_X1000_SSCR1_CHANGE_MASK ; +}
These functions would be much better written as switch statements - think how they're going to look when we've got another controller which needs custom values. It might also be helpful for review to have two patches, one splitting things out into the functions and another adding the Quark support.
drivers/spi/spi-pxa2xx.c static irqreturn_t ssp_int(int irq, void *dev_id) · line 704
Quoted 3 lines
drivers/spi/spi-pxa2xx.c +3
-0+/* see Quark SPI data sheet for implementation rationale */ +static u32 quark_x1000_set_clk_regvals (u32 rate,u32 *dds,u32 *clk_div) +{
Please document this in the driver - I don't know if this datasheet is public but even if it is it may not stay that way.
drivers/spi/spi-pxa2xx.c static void pump_transfers(unsigned long data) · line 764
Quoted 7 lines
drivers/spi/spi-pxa2xx.c +2
-0@@ -613,6 +759,8 @@ static void pump_transfers(unsigned long data)u32 cr1;u32 dma_thresh = drv_data->cur_chip->dma_threshold;u32 dma_burst = drv_data->cur_chip->dma_burst_size; +u32 change_mask =pxa2xx_spi_get_ssrc1_change_mask (drv_data); +
Extra blank line being added here.
drivers/spi/spi-pxa2xx.h static inline int pxa25x_ssp_comp(struct driver_data *drv_data) · line 154
Quoted 9 lines
drivers/spi/spi-pxa2xx.h +3
-0@@ -145,6 +147,9 @@ static inline int pxa25x_ssp_comp(struct driver_data *drv_data)return 1 ;if (drv_data->ssp_type ==CE4100_SSP )return 1 ; +if (drv_data->ssp_type ==QUARK_X1000_SSP ) +return 1 ; +return 0 ; }
Things like this should also be refactored into switch statements - in
general anything that's deciding what to do based on ssp_type probably
ought to be using switch statements.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 473 bytes
Desc: Digital signature
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20140926/234a5096/attachment.sig>
Andy Shevchenko
reviewerRe: [PATCH] SPI: spi-pxa2xx: SPI support for Intel Quark X1000
Quoted 1 line · Mark Brown
On Fri, Sep 26, 2014 at 10:25:49AM -0700, Weike Chen wrote:
[]
Quoted 3 lines
It might also be helpful for review to have two
patches, one splitting things out into the functions and another adding the Quark support.
I also suggest to go this way.
Quoted 7 lines
drivers/spi/spi-pxa2xx.c static irqreturn_t ssp_int(int irq, void *dev_id) · line 704
Quoted 4 lines
drivers/spi/spi-pxa2xx.c +3
-0+/* see Quark SPI data sheet for implementation rationale */ +static u32 quark_x1000_set_clk_regvals (u32 rate,u32 *dds,u32 *clk_div) +{Please document this in the driver - I don't know if this datasheet is public but even if it is it may not stay that way.
Datasheet is public.
I'm just wondering if we can use just a formula instead of table.
Signature · 2 lines
Andy Shevchenko <[email protected]> Intel Finland Oy
RE: [PATCH] SPI: spi-pxa2xx: SPI support for Intel Quark X1000
In reply to Mark BrownQuoted 14 lines
drivers/spi/spi-pxa2xx.c static bool is_lpss_ssp(const struct driver_data *drv_data)
Quoted 8 lines
drivers/spi/spi-pxa2xx.c +6
-0+static u32 pxa2xx_spi_get_ssrc1_change_mask (const struct driver_data +*drv_data) { +if (!is_quark_x1000_ssp (drv_data)) +return SSCR1_CHANGE_MASK ; + +return QUARK_X1000_SSCR1_CHANGE_MASK ; }These functions would be much better written as switch statements - think how they're going to look when we've got another controller which needs custom values. It might also be helpful for review to have two patches, one splitting things out into the functions and another adding the Quark support.
OK. Let me use switch. BTW, for two patches, actually, using helpers is due to we support quark. Do you mean the first patch just introduce helpers, maybe it only support one type, then another patch to add quark supporting. Am I right?
Quoted 5 lines
Review
Quoted 2 lines
(quoted diff) +2
-0+/* see Quark SPI data sheet for implementation rationale */ static +u32 quark_x1000_set_clk_regvals(u32 rate, u32 *dds, u32 *clk_div) {Please document this in the driver - I don't know if this datasheet is public but even if it is it may not stay that way.
OK. I will document it.
Quoted 11 lines
drivers/spi/spi-pxa2xx.c static void pump_transfers(unsigned long data) · line 764
Quoted 8 lines
drivers/spi/spi-pxa2xx.c +2
-0@@ -613,6 +759,8 @@ static void pump_transfers(unsigned long data)u32 cr1;u32 dma_thresh = drv_data->cur_chip->dma_threshold;u32 dma_burst = drv_data->cur_chip->dma_burst_size; +u32 change_mask =pxa2xx_spi_get_ssrc1_change_mask (drv_data); +Extra blank line being added here.
I will remove it.
Quoted 14 lines
Review static inline int pxa25x_ssp_comp(struct driver_data
Quoted 1 line
(quoted diff) +0
-0@@ -145,6 +147,9 @@ static inline int pxa25x_ssp_comp(struct driver_data
*drv_data)drivers/spi/spi-pxa2xx.h static inline int pxa25x_ssp_comp(struct driver_data *drv_data) · line 154
Quoted 8 lines
drivers/spi/spi-pxa2xx.h +3
-0return 1 ;if (drv_data->ssp_type ==CE4100_SSP )return 1 ; +if (drv_data->ssp_type ==QUARK_X1000_SSP ) +return 1 ; +return 0 ; }Things like this should also be refactored into switch statements - in general anything that's deciding what to do based on
ssp_typeprobably ought to be using switch statements.
OK. I will use switch.
RE: [PATCH] SPI: spi-pxa2xx: SPI support for Intel Quark X1000
In reply to Andy ShevchenkoQuoted 11 lines
Quoted 7 lines
Review
Quoted 4 lines
(quoted diff) +2
-0+/* see Quark SPI data sheet for implementation rationale */ static +u32 quark_x1000_set_clk_regvals(u32 rate, u32 *dds, u32 *clk_div) {Please document this in the driver - I don't know if this datasheet is public but even if it is it may not stay that way.
Datasheet is public.
I'm just wondering if we can use just a formula instead of table.
As I said before, there are two formulas, but for the given rate, from the formulas, we can get a lot of <dds, clk_div> pairs, and we also need to select them according to the guidelines which is not formula. The table the datasheet given should be the best one to meet the jitter and duty cycles as the datasheet documented.