Skip to content

Commit bab4d75

Browse files
committed
Merge remote-tracking branches 'spi/topic/pl022', 'spi/topic/pxa2xx', 'spi/topic/rspi', 'spi/topic/sh-msiof' and 'spi/topic/sirf' into spi-next
6 parents 899d81b + db4fa45 + 468e0f4 + 6089af7 + e221cc9 + 9593e61 commit bab4d75

File tree

9 files changed

+226
-113
lines changed

9 files changed

+226
-113
lines changed

Documentation/devicetree/bindings/spi/sh-msiof.txt

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,17 @@ Required properties:
66
"renesas,sh-mobile-msiof" for SH Mobile series.
77
Examples with soctypes are:
88
"renesas,msiof-r8a7790" (R-Car H2)
9-
"renesas,msiof-r8a7791" (R-Car M2)
10-
- reg : Offset and length of the register set for the device
9+
"renesas,msiof-r8a7791" (R-Car M2-W)
10+
"renesas,msiof-r8a7792" (R-Car V2H)
11+
"renesas,msiof-r8a7793" (R-Car M2-N)
12+
"renesas,msiof-r8a7794" (R-Car E2)
13+
- reg : A list of offsets and lengths of the register sets for
14+
the device.
15+
If only one register set is present, it is to be used
16+
by both the CPU and the DMA engine.
17+
If two register sets are present, the first is to be
18+
used by the CPU, and the second is to be used by the
19+
DMA engine.
1120
- interrupt-parent : The phandle for the interrupt controller that
1221
services interrupts for this device
1322
- interrupts : Interrupt specifier
@@ -17,12 +26,16 @@ Required properties:
1726
Optional properties:
1827
- clocks : Must contain a reference to the functional clock.
1928
- num-cs : Total number of chip-selects (default is 1)
29+
- dmas : Must contain a list of two references to DMA
30+
specifiers, one for transmission, and one for
31+
reception.
32+
- dma-names : Must contain a list of two DMA names, "tx" and "rx".
2033

2134
Optional properties, deprecated for soctype-specific bindings:
2235
- renesas,tx-fifo-size : Overrides the default tx fifo size given in words
2336
(default is 64)
2437
- renesas,rx-fifo-size : Overrides the default rx fifo size given in words
25-
(default is 64, or 256 on R-Car H2 and M2)
38+
(default is 64, or 256 on R-Car Gen2)
2639

2740
Pinctrl properties might be needed, too. See
2841
Documentation/devicetree/bindings/pinctrl/renesas,*.
@@ -31,9 +44,11 @@ Example:
3144

3245
msiof0: spi@e6e20000 {
3346
compatible = "renesas,msiof-r8a7791";
34-
reg = <0 0xe6e20000 0 0x0064>;
47+
reg = <0 0xe6e20000 0 0x0064>, <0 0xe7e20000 0 0x0064>;
3548
interrupts = <0 156 IRQ_TYPE_LEVEL_HIGH>;
3649
clocks = <&mstp0_clks R8A7791_CLK_MSIOF0>;
50+
dmas = <&dmac0 0x51>, <&dmac0 0x52>;
51+
dma-names = "tx", "rx";
3752
#address-cells = <1>;
3853
#size-cells = <0>;
3954
status = "disabled";

Documentation/devicetree/bindings/spi/spi-rspi.txt

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,10 @@ Required properties:
1111
- "renesas,rspi-sh7757" (SH)
1212
- "renesas,rspi-r7s72100" (RZ/A1H)
1313
- "renesas,qspi-r8a7790" (R-Car H2)
14-
- "renesas,qspi-r8a7791" (R-Car M2)
14+
- "renesas,qspi-r8a7791" (R-Car M2-W)
15+
- "renesas,qspi-r8a7792" (R-Car V2H)
16+
- "renesas,qspi-r8a7793" (R-Car M2-N)
17+
- "renesas,qspi-r8a7794" (R-Car E2)
1518
- reg : Address start and address range size of the device
1619
- interrupts : A list of interrupt-specifiers, one for each entry in
1720
interrupt-names.
@@ -30,6 +33,9 @@ Required properties:
3033

3134
Optional properties:
3235
- clocks : Must contain a reference to the functional clock.
36+
- dmas : Must contain a list of two references to DMA specifiers,
37+
one for transmission, and one for reception.
38+
- dma-names : Must contain a list of two DMA names, "tx" and "rx".
3339

3440
Pinctrl properties might be needed, too. See
3541
Documentation/devicetree/bindings/pinctrl/renesas,*.
@@ -58,4 +64,6 @@ Examples:
5864
num-cs = <1>;
5965
#address-cells = <1>;
6066
#size-cells = <0>;
67+
dmas = <&dmac0 0x17>, <&dmac0 0x18>;
68+
dma-names = "tx", "rx";
6169
};

drivers/spi/Kconfig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -391,7 +391,7 @@ config SPI_PXA2XX
391391
additional documentation can be found a Documentation/spi/pxa2xx.
392392

393393
config SPI_PXA2XX_PCI
394-
def_tristate SPI_PXA2XX && PCI
394+
def_tristate SPI_PXA2XX && PCI && COMMON_CLK
395395

396396
config SPI_ROCKCHIP
397397
tristate "Rockchip SPI controller driver"

drivers/spi/spi-pl022.c

Lines changed: 63 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@
8282
#define SSP_MIS(r) (r + 0x01C)
8383
#define SSP_ICR(r) (r + 0x020)
8484
#define SSP_DMACR(r) (r + 0x024)
85+
#define SSP_CSR(r) (r + 0x030) /* vendor extension */
8586
#define SSP_ITCR(r) (r + 0x080)
8687
#define SSP_ITIP(r) (r + 0x084)
8788
#define SSP_ITOP(r) (r + 0x088)
@@ -197,6 +198,12 @@
197198
/* Transmit DMA Enable bit */
198199
#define SSP_DMACR_MASK_TXDMAE (0x1UL << 1)
199200

201+
/*
202+
* SSP Chip Select Control Register - SSP_CSR
203+
* (vendor extension)
204+
*/
205+
#define SSP_CSR_CSVALUE_MASK (0x1FUL << 0)
206+
200207
/*
201208
* SSP Integration Test control Register - SSP_ITCR
202209
*/
@@ -313,6 +320,7 @@ enum ssp_writing {
313320
* @extended_cr: 32 bit wide control register 0 with extra
314321
* features and extra features in CR1 as found in the ST variants
315322
* @pl023: supports a subset of the ST extensions called "PL023"
323+
* @internal_cs_ctrl: supports chip select control register
316324
*/
317325
struct vendor_data {
318326
int fifodepth;
@@ -321,6 +329,7 @@ struct vendor_data {
321329
bool extended_cr;
322330
bool pl023;
323331
bool loopback;
332+
bool internal_cs_ctrl;
324333
};
325334

326335
/**
@@ -440,9 +449,32 @@ static void null_cs_control(u32 command)
440449
pr_debug("pl022: dummy chip select control, CS=0x%x\n", command);
441450
}
442451

452+
/**
453+
* internal_cs_control - Control chip select signals via SSP_CSR.
454+
* @pl022: SSP driver private data structure
455+
* @command: select/delect the chip
456+
*
457+
* Used on controller with internal chip select control via SSP_CSR register
458+
* (vendor extension). Each of the 5 LSB in the register controls one chip
459+
* select signal.
460+
*/
461+
static void internal_cs_control(struct pl022 *pl022, u32 command)
462+
{
463+
u32 tmp;
464+
465+
tmp = readw(SSP_CSR(pl022->virtbase));
466+
if (command == SSP_CHIP_SELECT)
467+
tmp &= ~BIT(pl022->cur_cs);
468+
else
469+
tmp |= BIT(pl022->cur_cs);
470+
writew(tmp, SSP_CSR(pl022->virtbase));
471+
}
472+
443473
static void pl022_cs_control(struct pl022 *pl022, u32 command)
444474
{
445-
if (gpio_is_valid(pl022->cur_cs))
475+
if (pl022->vendor->internal_cs_ctrl)
476+
internal_cs_control(pl022, command);
477+
else if (gpio_is_valid(pl022->cur_cs))
446478
gpio_set_value(pl022->cur_cs, command);
447479
else
448480
pl022->cur_chip->cs_control(command);
@@ -2100,6 +2132,10 @@ static int pl022_probe(struct amba_device *adev, const struct amba_id *id)
21002132
pl022->vendor = id->data;
21012133
pl022->chipselects = devm_kzalloc(dev, num_cs * sizeof(int),
21022134
GFP_KERNEL);
2135+
if (!pl022->chipselects) {
2136+
status = -ENOMEM;
2137+
goto err_no_mem;
2138+
}
21032139

21042140
/*
21052141
* Bus Number Which has been Assigned to this SSP controller
@@ -2118,6 +2154,9 @@ static int pl022_probe(struct amba_device *adev, const struct amba_id *id)
21182154
if (platform_info->num_chipselect && platform_info->chipselects) {
21192155
for (i = 0; i < num_cs; i++)
21202156
pl022->chipselects[i] = platform_info->chipselects[i];
2157+
} else if (pl022->vendor->internal_cs_ctrl) {
2158+
for (i = 0; i < num_cs; i++)
2159+
pl022->chipselects[i] = i;
21212160
} else if (IS_ENABLED(CONFIG_OF)) {
21222161
for (i = 0; i < num_cs; i++) {
21232162
int cs_gpio = of_get_named_gpio(np, "cs-gpios", i);
@@ -2241,6 +2280,7 @@ static int pl022_probe(struct amba_device *adev, const struct amba_id *id)
22412280
amba_release_regions(adev);
22422281
err_no_ioregion:
22432282
err_no_gpio:
2283+
err_no_mem:
22442284
spi_master_put(master);
22452285
return status;
22462286
}
@@ -2347,6 +2387,7 @@ static struct vendor_data vendor_arm = {
23472387
.extended_cr = false,
23482388
.pl023 = false,
23492389
.loopback = true,
2390+
.internal_cs_ctrl = false,
23502391
};
23512392

23522393
static struct vendor_data vendor_st = {
@@ -2356,6 +2397,7 @@ static struct vendor_data vendor_st = {
23562397
.extended_cr = true,
23572398
.pl023 = false,
23582399
.loopback = true,
2400+
.internal_cs_ctrl = false,
23592401
};
23602402

23612403
static struct vendor_data vendor_st_pl023 = {
@@ -2365,6 +2407,17 @@ static struct vendor_data vendor_st_pl023 = {
23652407
.extended_cr = true,
23662408
.pl023 = true,
23672409
.loopback = false,
2410+
.internal_cs_ctrl = false,
2411+
};
2412+
2413+
static struct vendor_data vendor_lsi = {
2414+
.fifodepth = 8,
2415+
.max_bpw = 16,
2416+
.unidir = false,
2417+
.extended_cr = false,
2418+
.pl023 = false,
2419+
.loopback = true,
2420+
.internal_cs_ctrl = true,
23682421
};
23692422

23702423
static struct amba_id pl022_ids[] = {
@@ -2398,6 +2451,15 @@ static struct amba_id pl022_ids[] = {
23982451
.mask = 0xffffffff,
23992452
.data = &vendor_st_pl023,
24002453
},
2454+
{
2455+
/*
2456+
* PL022 variant that has a chip select control register whih
2457+
* allows control of 5 output signals nCS[0:4].
2458+
*/
2459+
.id = 0x000b6022,
2460+
.mask = 0x000fffff,
2461+
.data = &vendor_lsi,
2462+
},
24012463
{ 0, 0 },
24022464
};
24032465

drivers/spi/spi-pxa2xx-pci.c

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77
#include <linux/of_device.h>
88
#include <linux/module.h>
99
#include <linux/spi/pxa2xx_spi.h>
10+
#include <linux/clk.h>
11+
#include <linux/clk-provider.h>
1012

1113
enum {
1214
PORT_CE4100,
@@ -21,6 +23,7 @@ struct pxa_spi_info {
2123
int tx_chan_id;
2224
int rx_slave_id;
2325
int rx_chan_id;
26+
unsigned long max_clk_rate;
2427
};
2528

2629
static struct pxa_spi_info spi_info_configs[] = {
@@ -32,6 +35,7 @@ static struct pxa_spi_info spi_info_configs[] = {
3235
.tx_chan_id = -1,
3336
.rx_slave_id = -1,
3437
.rx_chan_id = -1,
38+
.max_clk_rate = 3686400,
3539
},
3640
[PORT_BYT] = {
3741
.type = LPSS_SSP,
@@ -41,6 +45,7 @@ static struct pxa_spi_info spi_info_configs[] = {
4145
.tx_chan_id = 0,
4246
.rx_slave_id = 1,
4347
.rx_chan_id = 1,
48+
.max_clk_rate = 50000000,
4449
},
4550
};
4651

@@ -53,6 +58,7 @@ static int pxa2xx_spi_pci_probe(struct pci_dev *dev,
5358
struct pxa2xx_spi_master spi_pdata;
5459
struct ssp_device *ssp;
5560
struct pxa_spi_info *c;
61+
char buf[40];
5662

5763
ret = pcim_enable_device(dev);
5864
if (ret)
@@ -84,6 +90,12 @@ static int pxa2xx_spi_pci_probe(struct pci_dev *dev,
8490
ssp->port_id = (c->port_id >= 0) ? c->port_id : dev->devfn;
8591
ssp->type = c->type;
8692

93+
snprintf(buf, sizeof(buf), "pxa2xx-spi.%d", ssp->port_id);
94+
ssp->clk = clk_register_fixed_rate(&dev->dev, buf , NULL,
95+
CLK_IS_ROOT, c->max_clk_rate);
96+
if (IS_ERR(ssp->clk))
97+
return PTR_ERR(ssp->clk);
98+
8799
memset(&pi, 0, sizeof(pi));
88100
pi.parent = &dev->dev;
89101
pi.name = "pxa2xx-spi";
@@ -92,8 +104,10 @@ static int pxa2xx_spi_pci_probe(struct pci_dev *dev,
92104
pi.size_data = sizeof(spi_pdata);
93105

94106
pdev = platform_device_register_full(&pi);
95-
if (IS_ERR(pdev))
107+
if (IS_ERR(pdev)) {
108+
clk_unregister(ssp->clk);
96109
return PTR_ERR(pdev);
110+
}
97111

98112
pci_set_drvdata(dev, pdev);
99113

@@ -103,8 +117,12 @@ static int pxa2xx_spi_pci_probe(struct pci_dev *dev,
103117
static void pxa2xx_spi_pci_remove(struct pci_dev *dev)
104118
{
105119
struct platform_device *pdev = pci_get_drvdata(dev);
120+
struct pxa2xx_spi_master *spi_pdata;
121+
122+
spi_pdata = dev_get_platdata(&pdev->dev);
106123

107124
platform_device_unregister(pdev);
125+
clk_unregister(spi_pdata->ssp.clk);
108126
}
109127

110128
static const struct pci_device_id pxa2xx_spi_pci_devices[] = {

0 commit comments

Comments
 (0)