Commit b769c5ba authored by Mark Brown's avatar Mark Brown

Merge branch 'spi-5.4' into spi-next

parents 262a2f33 fdeae8f5
* Nuvoton FLASH Interface Unit (FIU) SPI Controller
NPCM FIU supports single, dual and quad communication interface.
The NPCM7XX supports three FIU modules,
FIU0 and FIUx supports two chip selects,
FIU3 support four chip select.
Required properties:
- compatible : "nuvoton,npcm750-fiu" for the NPCM7XX BMC
- #address-cells : should be 1.
- #size-cells : should be 0.
- reg : the first contains the register location and length,
the second contains the memory mapping address and length
- reg-names: Should contain the reg names "control" and "memory"
- clocks : phandle of FIU reference clock.
Required properties in case the pins can be muxed:
- pinctrl-names : a pinctrl state named "default" must be defined.
- pinctrl-0 : phandle referencing pin configuration of the device.
Optional property:
- nuvoton,spix-mode: enable spix-mode for an expansion bus to an ASIC or CPLD.
Aliases:
- All the FIU controller nodes should be represented in the aliases node using
the following format 'fiu{n}' where n is a unique number for the alias.
In the NPCM7XX BMC:
fiu0 represent fiu 0 controller
fiu1 represent fiu 3 controller
fiu2 represent fiu x controller
Example:
fiu3: spi@c00000000 {
compatible = "nuvoton,npcm750-fiu";
#address-cells = <1>;
#size-cells = <0>;
reg = <0xfb000000 0x1000>, <0x80000000 0x10000000>;
reg-names = "control", "memory";
clocks = <&clk NPCM7XX_CLK_AHB>;
pinctrl-names = "default";
pinctrl-0 = <&spi3_pins>;
spi-nor@0 {
...
};
};
...@@ -3,9 +3,8 @@ ...@@ -3,9 +3,8 @@
Required properties: Required properties:
- compatible : Should be "fsl,vf610-qspi", "fsl,imx6sx-qspi", - compatible : Should be "fsl,vf610-qspi", "fsl,imx6sx-qspi",
"fsl,imx7d-qspi", "fsl,imx6ul-qspi", "fsl,imx7d-qspi", "fsl,imx6ul-qspi",
"fsl,ls1021a-qspi" "fsl,ls1021a-qspi", "fsl,ls2080a-qspi"
or or
"fsl,ls2080a-qspi" followed by "fsl,ls1021a-qspi",
"fsl,ls1043a-qspi" followed by "fsl,ls1021a-qspi" "fsl,ls1043a-qspi" followed by "fsl,ls1021a-qspi"
- reg : the first contains the register location and length, - reg : the first contains the register location and length,
the second contains the memory mapping address and length the second contains the memory mapping address and length
...@@ -34,7 +33,11 @@ qspi0: quadspi@40044000 { ...@@ -34,7 +33,11 @@ qspi0: quadspi@40044000 {
clock-names = "qspi_en", "qspi"; clock-names = "qspi_en", "qspi";
flash0: s25fl128s@0 { flash0: s25fl128s@0 {
.... #address-cells = <1>;
#size-cells = <1>;
compatible = "spansion,s25fl128s", "jedec,spi-nor";
spi-max-frequency = <50000000>;
reg = <0>;
}; };
}; };
......
...@@ -5,6 +5,7 @@ Required properties: ...@@ -5,6 +5,7 @@ Required properties:
- mediatek,mt2701-spi: for mt2701 platforms - mediatek,mt2701-spi: for mt2701 platforms
- mediatek,mt2712-spi: for mt2712 platforms - mediatek,mt2712-spi: for mt2712 platforms
- mediatek,mt6589-spi: for mt6589 platforms - mediatek,mt6589-spi: for mt6589 platforms
- mediatek,mt6765-spi: for mt6765 platforms
- mediatek,mt7622-spi: for mt7622 platforms - mediatek,mt7622-spi: for mt7622 platforms
- "mediatek,mt7629-spi", "mediatek,mt7622-spi": for mt7629 platforms - "mediatek,mt7629-spi", "mediatek,mt7622-spi": for mt7629 platforms
- mediatek,mt8135-spi: for mt8135 platforms - mediatek,mt8135-spi: for mt8135 platforms
......
...@@ -25,18 +25,23 @@ data by ADI software channels at the same time, or two parallel routine of setti ...@@ -25,18 +25,23 @@ data by ADI software channels at the same time, or two parallel routine of setti
ADI registers will make ADI controller registers chaos to lead incorrect results. ADI registers will make ADI controller registers chaos to lead incorrect results.
Then we need one hardware spinlock to synchronize between the multiple subsystems. Then we need one hardware spinlock to synchronize between the multiple subsystems.
The new version ADI controller supplies multiple master channels for different
subsystem accessing, that means no need to add hardware spinlock to synchronize,
thus change the hardware spinlock support to be optional to keep backward
compatibility.
Required properties: Required properties:
- compatible: Should be "sprd,sc9860-adi". - compatible: Should be "sprd,sc9860-adi".
- reg: Offset and length of ADI-SPI controller register space. - reg: Offset and length of ADI-SPI controller register space.
- hwlocks: Reference to a phandle of a hwlock provider node.
- hwlock-names: Reference to hwlock name strings defined in the same order
as the hwlocks, should be "adi".
- #address-cells: Number of cells required to define a chip select address - #address-cells: Number of cells required to define a chip select address
on the ADI-SPI bus. Should be set to 1. on the ADI-SPI bus. Should be set to 1.
- #size-cells: Size of cells required to define a chip select address size - #size-cells: Size of cells required to define a chip select address size
on the ADI-SPI bus. Should be set to 0. on the ADI-SPI bus. Should be set to 0.
Optional properties: Optional properties:
- hwlocks: Reference to a phandle of a hwlock provider node.
- hwlock-names: Reference to hwlock name strings defined in the same order
as the hwlocks, should be "adi".
- sprd,hw-channels: This is an array of channel values up to 49 channels. - sprd,hw-channels: This is an array of channel values up to 49 channels.
The first value specifies the hardware channel id which is used to The first value specifies the hardware channel id which is used to
transfer data triggered by hardware automatically, and the second transfer data triggered by hardware automatically, and the second
......
...@@ -103,7 +103,7 @@ static struct spi_board_info edb93xx_spi_board_info[] __initdata = { ...@@ -103,7 +103,7 @@ static struct spi_board_info edb93xx_spi_board_info[] __initdata = {
}; };
static struct gpiod_lookup_table edb93xx_spi_cs_gpio_table = { static struct gpiod_lookup_table edb93xx_spi_cs_gpio_table = {
.dev_id = "ep93xx-spi.0", .dev_id = "spi0",
.table = { .table = {
GPIO_LOOKUP("A", 6, "cs", GPIO_ACTIVE_LOW), GPIO_LOOKUP("A", 6, "cs", GPIO_ACTIVE_LOW),
{ }, { },
......
...@@ -73,7 +73,7 @@ static struct spi_board_info simone_spi_devices[] __initdata = { ...@@ -73,7 +73,7 @@ static struct spi_board_info simone_spi_devices[] __initdata = {
* v1.3 parts will still work, since the signal on SFRMOUT is automatic. * v1.3 parts will still work, since the signal on SFRMOUT is automatic.
*/ */
static struct gpiod_lookup_table simone_spi_cs_gpio_table = { static struct gpiod_lookup_table simone_spi_cs_gpio_table = {
.dev_id = "ep93xx-spi.0", .dev_id = "spi0",
.table = { .table = {
GPIO_LOOKUP("A", 1, "cs", GPIO_ACTIVE_LOW), GPIO_LOOKUP("A", 1, "cs", GPIO_ACTIVE_LOW),
{ }, { },
......
...@@ -267,7 +267,7 @@ static struct spi_board_info bk3_spi_board_info[] __initdata = { ...@@ -267,7 +267,7 @@ static struct spi_board_info bk3_spi_board_info[] __initdata = {
* goes through CPLD * goes through CPLD
*/ */
static struct gpiod_lookup_table bk3_spi_cs_gpio_table = { static struct gpiod_lookup_table bk3_spi_cs_gpio_table = {
.dev_id = "ep93xx-spi.0", .dev_id = "spi0",
.table = { .table = {
GPIO_LOOKUP("F", 3, "cs", GPIO_ACTIVE_LOW), GPIO_LOOKUP("F", 3, "cs", GPIO_ACTIVE_LOW),
{ }, { },
...@@ -316,7 +316,7 @@ static struct spi_board_info ts72xx_spi_devices[] __initdata = { ...@@ -316,7 +316,7 @@ static struct spi_board_info ts72xx_spi_devices[] __initdata = {
}; };
static struct gpiod_lookup_table ts72xx_spi_cs_gpio_table = { static struct gpiod_lookup_table ts72xx_spi_cs_gpio_table = {
.dev_id = "ep93xx-spi.0", .dev_id = "spi0",
.table = { .table = {
/* DIO_17 */ /* DIO_17 */
GPIO_LOOKUP("F", 2, "cs", GPIO_ACTIVE_LOW), GPIO_LOOKUP("F", 2, "cs", GPIO_ACTIVE_LOW),
......
...@@ -242,7 +242,7 @@ static struct spi_board_info vision_spi_board_info[] __initdata = { ...@@ -242,7 +242,7 @@ static struct spi_board_info vision_spi_board_info[] __initdata = {
}; };
static struct gpiod_lookup_table vision_spi_cs_gpio_table = { static struct gpiod_lookup_table vision_spi_cs_gpio_table = {
.dev_id = "ep93xx-spi.0", .dev_id = "spi0",
.table = { .table = {
GPIO_LOOKUP_IDX("A", 6, "cs", 0, GPIO_ACTIVE_LOW), GPIO_LOOKUP_IDX("A", 6, "cs", 0, GPIO_ACTIVE_LOW),
GPIO_LOOKUP_IDX("A", 7, "cs", 1, GPIO_ACTIVE_LOW), GPIO_LOOKUP_IDX("A", 7, "cs", 1, GPIO_ACTIVE_LOW),
......
...@@ -37,10 +37,19 @@ ...@@ -37,10 +37,19 @@
#define BCM2835_DMA_MAX_DMA_CHAN_SUPPORTED 14 #define BCM2835_DMA_MAX_DMA_CHAN_SUPPORTED 14
#define BCM2835_DMA_CHAN_NAME_SIZE 8 #define BCM2835_DMA_CHAN_NAME_SIZE 8
/**
* struct bcm2835_dmadev - BCM2835 DMA controller
* @ddev: DMA device
* @base: base address of register map
* @dma_parms: DMA parameters (to convey 1 GByte max segment size to clients)
* @zero_page: bus address of zero page (to detect transactions copying from
* zero page and avoid accessing memory if so)
*/
struct bcm2835_dmadev { struct bcm2835_dmadev {
struct dma_device ddev; struct dma_device ddev;
void __iomem *base; void __iomem *base;
struct device_dma_parameters dma_parms; struct device_dma_parameters dma_parms;
dma_addr_t zero_page;
}; };
struct bcm2835_dma_cb { struct bcm2835_dma_cb {
...@@ -687,11 +696,12 @@ static struct dma_async_tx_descriptor *bcm2835_dma_prep_dma_cyclic( ...@@ -687,11 +696,12 @@ static struct dma_async_tx_descriptor *bcm2835_dma_prep_dma_cyclic(
size_t period_len, enum dma_transfer_direction direction, size_t period_len, enum dma_transfer_direction direction,
unsigned long flags) unsigned long flags)
{ {
struct bcm2835_dmadev *od = to_bcm2835_dma_dev(chan->device);
struct bcm2835_chan *c = to_bcm2835_dma_chan(chan); struct bcm2835_chan *c = to_bcm2835_dma_chan(chan);
struct bcm2835_desc *d; struct bcm2835_desc *d;
dma_addr_t src, dst; dma_addr_t src, dst;
u32 info = BCM2835_DMA_WAIT_RESP; u32 info = BCM2835_DMA_WAIT_RESP;
u32 extra = BCM2835_DMA_INT_EN; u32 extra = 0;
size_t max_len = bcm2835_dma_max_frame_length(c); size_t max_len = bcm2835_dma_max_frame_length(c);
size_t frames; size_t frames;
...@@ -707,6 +717,11 @@ static struct dma_async_tx_descriptor *bcm2835_dma_prep_dma_cyclic( ...@@ -707,6 +717,11 @@ static struct dma_async_tx_descriptor *bcm2835_dma_prep_dma_cyclic(
return NULL; return NULL;
} }
if (flags & DMA_PREP_INTERRUPT)
extra |= BCM2835_DMA_INT_EN;
else
period_len = buf_len;
/* /*
* warn if buf_len is not a multiple of period_len - this may leed * warn if buf_len is not a multiple of period_len - this may leed
* to unexpected latencies for interrupts and thus audiable clicks * to unexpected latencies for interrupts and thus audiable clicks
...@@ -732,6 +747,10 @@ static struct dma_async_tx_descriptor *bcm2835_dma_prep_dma_cyclic( ...@@ -732,6 +747,10 @@ static struct dma_async_tx_descriptor *bcm2835_dma_prep_dma_cyclic(
dst = c->cfg.dst_addr; dst = c->cfg.dst_addr;
src = buf_addr; src = buf_addr;
info |= BCM2835_DMA_D_DREQ | BCM2835_DMA_S_INC; info |= BCM2835_DMA_D_DREQ | BCM2835_DMA_S_INC;
/* non-lite channels can write zeroes w/o accessing memory */
if (buf_addr == od->zero_page && !c->is_lite_channel)
info |= BCM2835_DMA_S_IGNORE;
} }
/* calculate number of frames */ /* calculate number of frames */
...@@ -778,7 +797,10 @@ static int bcm2835_dma_terminate_all(struct dma_chan *chan) ...@@ -778,7 +797,10 @@ static int bcm2835_dma_terminate_all(struct dma_chan *chan)
/* stop DMA activity */ /* stop DMA activity */
if (c->desc) { if (c->desc) {
vchan_terminate_vdesc(&c->desc->vd); if (c->desc->vd.tx.flags & DMA_PREP_INTERRUPT)
vchan_terminate_vdesc(&c->desc->vd);
else
vchan_vdesc_fini(&c->desc->vd);
c->desc = NULL; c->desc = NULL;
bcm2835_dma_abort(c); bcm2835_dma_abort(c);
} }
...@@ -831,6 +853,9 @@ static void bcm2835_dma_free(struct bcm2835_dmadev *od) ...@@ -831,6 +853,9 @@ static void bcm2835_dma_free(struct bcm2835_dmadev *od)
list_del(&c->vc.chan.device_node); list_del(&c->vc.chan.device_node);
tasklet_kill(&c->vc.task); tasklet_kill(&c->vc.task);
} }
dma_unmap_page_attrs(od->ddev.dev, od->zero_page, PAGE_SIZE,
DMA_TO_DEVICE, DMA_ATTR_SKIP_CPU_SYNC);
} }
static const struct of_device_id bcm2835_dma_of_match[] = { static const struct of_device_id bcm2835_dma_of_match[] = {
...@@ -907,11 +932,20 @@ static int bcm2835_dma_probe(struct platform_device *pdev) ...@@ -907,11 +932,20 @@ static int bcm2835_dma_probe(struct platform_device *pdev)
od->ddev.directions = BIT(DMA_DEV_TO_MEM) | BIT(DMA_MEM_TO_DEV) | od->ddev.directions = BIT(DMA_DEV_TO_MEM) | BIT(DMA_MEM_TO_DEV) |
BIT(DMA_MEM_TO_MEM); BIT(DMA_MEM_TO_MEM);
od->ddev.residue_granularity = DMA_RESIDUE_GRANULARITY_BURST; od->ddev.residue_granularity = DMA_RESIDUE_GRANULARITY_BURST;
od->ddev.descriptor_reuse = true;
od->ddev.dev = &pdev->dev; od->ddev.dev = &pdev->dev;
INIT_LIST_HEAD(&od->ddev.channels); INIT_LIST_HEAD(&od->ddev.channels);
platform_set_drvdata(pdev, od); platform_set_drvdata(pdev, od);
od->zero_page = dma_map_page_attrs(od->ddev.dev, ZERO_PAGE(0), 0,
PAGE_SIZE, DMA_TO_DEVICE,
DMA_ATTR_SKIP_CPU_SYNC);
if (dma_mapping_error(od->ddev.dev, od->zero_page)) {
dev_err(&pdev->dev, "Failed to map zero page\n");
return -ENOMEM;
}
/* Request DMA channel mask from device tree */ /* Request DMA channel mask from device tree */
if (of_property_read_u32(pdev->dev.of_node, if (of_property_read_u32(pdev->dev.of_node,
"brcm,dma-channel-mask", "brcm,dma-channel-mask",
......
...@@ -706,7 +706,7 @@ static int cros_ec_spi_devm_high_pri_alloc(struct device *dev, ...@@ -706,7 +706,7 @@ static int cros_ec_spi_devm_high_pri_alloc(struct device *dev,
struct cros_ec_spi *ec_spi) struct cros_ec_spi *ec_spi)
{ {
struct sched_param sched_priority = { struct sched_param sched_priority = {
.sched_priority = MAX_RT_PRIO - 1, .sched_priority = MAX_RT_PRIO / 2,
}; };
int err; int err;
......
...@@ -433,6 +433,16 @@ config SPI_MT7621 ...@@ -433,6 +433,16 @@ config SPI_MT7621
help help
This selects a driver for the MediaTek MT7621 SPI Controller. This selects a driver for the MediaTek MT7621 SPI Controller.
config SPI_NPCM_FIU
tristate "Nuvoton NPCM FLASH Interface Unit"
depends on ARCH_NPCM || COMPILE_TEST
depends on OF && HAS_IOMEM
help
This enables support for the Flash Interface Unit SPI controller
in master mode.
This driver does not support generic SPI. The implementation only
supports spi-mem interface.
config SPI_NPCM_PSPI config SPI_NPCM_PSPI
tristate "Nuvoton NPCM PSPI Controller" tristate "Nuvoton NPCM PSPI Controller"
depends on ARCH_NPCM || COMPILE_TEST depends on ARCH_NPCM || COMPILE_TEST
......
...@@ -63,6 +63,7 @@ obj-$(CONFIG_SPI_MT65XX) += spi-mt65xx.o ...@@ -63,6 +63,7 @@ obj-$(CONFIG_SPI_MT65XX) += spi-mt65xx.o
obj-$(CONFIG_SPI_MT7621) += spi-mt7621.o obj-$(CONFIG_SPI_MT7621) += spi-mt7621.o
obj-$(CONFIG_SPI_MXIC) += spi-mxic.o obj-$(CONFIG_SPI_MXIC) += spi-mxic.o
obj-$(CONFIG_SPI_MXS) += spi-mxs.o obj-$(CONFIG_SPI_MXS) += spi-mxs.o
obj-$(CONFIG_SPI_NPCM_FIU) += spi-npcm-fiu.o
obj-$(CONFIG_SPI_NPCM_PSPI) += spi-npcm-pspi.o obj-$(CONFIG_SPI_NPCM_PSPI) += spi-npcm-pspi.o
obj-$(CONFIG_SPI_NUC900) += spi-nuc900.o obj-$(CONFIG_SPI_NUC900) += spi-nuc900.o
obj-$(CONFIG_SPI_NXP_FLEXSPI) += spi-nxp-fspi.o obj-$(CONFIG_SPI_NXP_FLEXSPI) += spi-nxp-fspi.o
......
...@@ -526,7 +526,6 @@ static int atmel_qspi_probe(struct platform_device *pdev) ...@@ -526,7 +526,6 @@ static int atmel_qspi_probe(struct platform_device *pdev)
/* Request the IRQ */ /* Request the IRQ */
irq = platform_get_irq(pdev, 0); irq = platform_get_irq(pdev, 0);
if (irq < 0) { if (irq < 0) {
dev_err(&pdev->dev, "missing IRQ\n");
err = irq; err = irq;
goto disable_qspick; goto disable_qspick;
} }
......
...@@ -170,7 +170,6 @@ static int altera_spi_probe(struct platform_device *pdev) ...@@ -170,7 +170,6 @@ static int altera_spi_probe(struct platform_device *pdev)
{ {
struct altera_spi *hw; struct altera_spi *hw;
struct spi_master *master; struct spi_master *master;
struct resource *res;
int err = -ENODEV; int err = -ENODEV;
master = spi_alloc_master(&pdev->dev, sizeof(struct altera_spi)); master = spi_alloc_master(&pdev->dev, sizeof(struct altera_spi));
...@@ -189,8 +188,7 @@ static int altera_spi_probe(struct platform_device *pdev) ...@@ -189,8 +188,7 @@ static int altera_spi_probe(struct platform_device *pdev)
hw = spi_master_get_devdata(master); hw = spi_master_get_devdata(master);
/* find and map our resources */ /* find and map our resources */
res = platform_get_resource(pdev, IORESOURCE_MEM, 0); hw->base = devm_platform_ioremap_resource(pdev, 0);
hw->base = devm_ioremap_resource(&pdev->dev, res);
if (IS_ERR(hw->base)) { if (IS_ERR(hw->base)) {
err = PTR_ERR(hw->base); err = PTR_ERR(hw->base);
goto exit; goto exit;
......
...@@ -817,7 +817,6 @@ static int a3700_spi_probe(struct platform_device *pdev) ...@@ -817,7 +817,6 @@ static int a3700_spi_probe(struct platform_device *pdev)
{ {
struct device *dev = &pdev->dev; struct device *dev = &pdev->dev;
struct device_node *of_node = dev->of_node; struct device_node *of_node = dev->of_node;
struct resource *res;
struct spi_master *master; struct spi_master *master;
struct a3700_spi *spi; struct a3700_spi *spi;
u32 num_cs = 0; u32 num_cs = 0;
...@@ -855,8 +854,7 @@ static int a3700_spi_probe(struct platform_device *pdev) ...@@ -855,8 +854,7 @@ static int a3700_spi_probe(struct platform_device *pdev)
spi->master = master; spi->master = master;
res = platform_get_resource(pdev, IORESOURCE_MEM, 0); spi->base = devm_platform_ioremap_resource(pdev, 0);
spi->base = devm_ioremap_resource(dev, res);
if (IS_ERR(spi->base)) { if (IS_ERR(spi->base)) {
ret = PTR_ERR(spi->base); ret = PTR_ERR(spi->base);
goto error; goto error;
...@@ -864,7 +862,6 @@ static int a3700_spi_probe(struct platform_device *pdev) ...@@ -864,7 +862,6 @@ static int a3700_spi_probe(struct platform_device *pdev)
irq = platform_get_irq(pdev, 0); irq = platform_get_irq(pdev, 0);
if (irq < 0) { if (irq < 0) {
dev_err(dev, "could not get irq: %d\n", irq);
ret = -ENXIO; ret = -ENXIO;
goto error; goto error;
} }
......
...@@ -139,7 +139,6 @@ static int ath79_spi_probe(struct platform_device *pdev) ...@@ -139,7 +139,6 @@ static int ath79_spi_probe(struct platform_device *pdev)
struct spi_master *master; struct spi_master *master;
struct ath79_spi *sp; struct ath79_spi *sp;
struct ath79_spi_platform_data *pdata; struct ath79_spi_platform_data *pdata;
struct resource *r;
unsigned long rate; unsigned long rate;
int ret; int ret;
...@@ -169,8 +168,7 @@ static int ath79_spi_probe(struct platform_device *pdev) ...@@ -169,8 +168,7 @@ static int ath79_spi_probe(struct platform_device *pdev)
sp->bitbang.txrx_word[SPI_MODE_0] = ath79_spi_txrx_mode0; sp->bitbang.txrx_word[SPI_MODE_0] = ath79_spi_txrx_mode0;
sp->bitbang.flags = SPI_CS_HIGH; sp->bitbang.flags = SPI_CS_HIGH;
r = platform_get_resource(pdev, IORESOURCE_MEM, 0); sp->base = devm_platform_ioremap_resource(pdev, 0);
sp->base = devm_ioremap_resource(&pdev->dev, r);
if (IS_ERR(sp->base)) { if (IS_ERR(sp->base)) {
ret = PTR_ERR(sp->base); ret = PTR_ERR(sp->base);
goto err_put_master; goto err_put_master;
......
...@@ -23,6 +23,7 @@ ...@@ -23,6 +23,7 @@
#include <linux/gpio/consumer.h> #include <linux/gpio/consumer.h>
#include <linux/pinctrl/consumer.h> #include <linux/pinctrl/consumer.h>
#include <linux/pm_runtime.h> #include <linux/pm_runtime.h>
#include <trace/events/spi.h>
/* SPI register offsets */ /* SPI register offsets */
#define SPI_CR 0x0000 #define SPI_CR 0x0000
...@@ -1409,9 +1410,13 @@ static int atmel_spi_transfer_one_message(struct spi_master *master, ...@@ -1409,9 +1410,13 @@ static int atmel_spi_transfer_one_message(struct spi_master *master,
msg->actual_length = 0; msg->actual_length = 0;
list_for_each_entry(xfer, &msg->transfers, transfer_list) { list_for_each_entry(xfer, &msg->transfers, transfer_list) {
trace_spi_transfer_start(msg, xfer);
ret = atmel_spi_one_transfer(master, msg, xfer); ret = atmel_spi_one_transfer(master, msg, xfer);
if (ret) if (ret)
goto msg_done; goto msg_done;
trace_spi_transfer_stop(msg, xfer);
} }
if (as->use_pdc) if (as->use_pdc)
......
...@@ -460,7 +460,6 @@ static int spi_engine_probe(struct platform_device *pdev) ...@@ -460,7 +460,6 @@ static int spi_engine_probe(struct platform_device *pdev)
struct spi_engine *spi_engine; struct spi_engine *spi_engine;
struct spi_master *master; struct spi_master *master;
unsigned int version; unsigned int version;
struct resource *res;
int irq; int irq;
int ret; int ret;
...@@ -480,8 +479,7 @@ static int spi_engine_probe(struct platform_device *pdev) ...@@ -480,8 +479,7 @@ static int spi_engine_probe(struct platform_device *pdev)
spin_lock_init(&spi_engine->lock); spin_lock_init(&spi_engine->lock);
res = platform_get_resource(pdev, IORESOURCE_MEM, 0); spi_engine->base = devm_platform_ioremap_resource(pdev, 0);
spi_engine->base = devm_ioremap_resource(&pdev->dev, res);
if (IS_ERR(spi_engine->base)) { if (IS_ERR(spi_engine->base)) {
ret = PTR_ERR(spi_engine->base); ret = PTR_ERR(spi_engine->base);
goto err_put_master; goto err_put_master;
......
...@@ -897,6 +897,7 @@ static int bcm_qspi_transfer_one(struct spi_master *master, ...@@ -897,6 +897,7 @@ static int bcm_qspi_transfer_one(struct spi_master *master,
read_from_hw(qspi, slots); read_from_hw(qspi, slots);
} }
bcm_qspi_enable_bspi(qspi);
return 0; return 0;
} }
......
This diff is collapsed.
...@@ -491,7 +491,6 @@ static int bcm2835aux_spi_probe(struct platform_device *pdev) ...@@ -491,7 +491,6 @@ static int bcm2835aux_spi_probe(struct platform_device *pdev)
{ {
struct spi_master *master; struct spi_master *master;
struct bcm2835aux_spi *bs; struct bcm2835aux_spi *bs;
struct resource *res;
unsigned long clk_hz; unsigned long clk_hz;
int err; int err;
...@@ -524,8 +523,7 @@ static int bcm2835aux_spi_probe(struct platform_device *pdev) ...@@ -524,8 +523,7 @@ static int bcm2835aux_spi_probe(struct platform_device *pdev)
bs = spi_master_get_devdata(master); bs = spi_master_get_devdata(master);
/* the main area */ /* the main area */
res = platform_get_resource(pdev, IORESOURCE_MEM, 0); bs->regs = devm_platform_ioremap_resource(pdev, 0);
bs->regs = devm_ioremap_resource(&pdev->dev, res);
if (IS_ERR(bs->regs)) { if (IS_ERR(bs->regs)) {
err = PTR_ERR(bs->regs); err = PTR_ERR(bs->regs);
goto out_master_put; goto out_master_put;
...@@ -540,7 +538,6 @@ static int bcm2835aux_spi_probe(struct platform_device *pdev) ...@@ -540,7 +538,6 @@ static int bcm2835aux_spi_probe(struct platform_device *pdev)
bs->irq = platform_get_irq(pdev, 0); bs->irq = platform_get_irq(pdev, 0);
if (bs->irq <= 0) { if (bs->irq <= 0) {
dev_err(&pdev->dev, "could not get IRQ: %d\n", bs->irq);
err = bs->irq ? bs->irq : -ENODEV; err = bs->irq ? bs->irq : -ENODEV;
goto out_master_put; goto out_master_put;
} }
......
...@@ -330,7 +330,6 @@ static int bcm63xx_hsspi_probe(struct platform_device *pdev) ...@@ -330,7 +330,6 @@ static int bcm63xx_hsspi_probe(struct platform_device *pdev)
{ {
struct spi_master *master; struct spi_master *master;
struct bcm63xx_hsspi *bs; struct bcm63xx_hsspi *bs;
struct resource *res_mem;
void __iomem *regs; void __iomem *regs;
struct device *dev = &pdev->dev; struct device *dev = &pdev->dev;
struct clk *clk, *pll_clk = NULL; struct clk *clk, *pll_clk = NULL;
...@@ -338,13 +337,10 @@ static int bcm63xx_hsspi_probe(struct platform_device *pdev) ...@@ -338,13 +337,10 @@ static int bcm63xx_hsspi_probe(struct platform_device *pdev)
u32 reg, rate, num_cs = HSSPI_SPI_MAX_CS; u32 reg, rate, num_cs = HSSPI_SPI_MAX_CS;
irq = platform_get_irq(pdev, 0); irq = platform_get_irq(pdev, 0);
if (irq < 0) { if (irq < 0)
dev_err(dev, "no irq: %d\n", irq);
return irq; return irq;
}
res_mem = platform_get_resource(pdev, IORESOURCE_MEM, 0); regs = devm_platform_ioremap_resource(pdev, 0);
regs = devm_ioremap_resource(dev, res_mem);
if (IS_ERR(regs)) if (IS_ERR(regs))
return PTR_ERR(regs); return PTR_ERR(regs);
......
...@@ -520,10 +520,8 @@ static int bcm63xx_spi_probe(struct platform_device *pdev) ...@@ -520,10 +520,8 @@ static int bcm63xx_spi_probe(struct platform_device *pdev)
} }
irq = platform_get_irq(pdev, 0); irq = platform_get_irq(pdev, 0);
if (irq < 0) { if (irq < 0)
dev_err(dev, "no irq: %d\n", irq);
return irq; return irq;
}
clk = devm_clk_get(dev, "spi"); clk = devm_clk_get(dev, "spi");
if (IS_ERR(clk)) { if (IS_ERR(clk)) {
......
...@@ -474,7 +474,6 @@ static int cdns_spi_probe(struct platform_device *pdev) ...@@ -474,7 +474,6 @@ static int cdns_spi_probe(struct platform_device *pdev)
int ret = 0, irq; int ret = 0, irq;
struct spi_master *master; struct spi_master *master;
struct cdns_spi *xspi; struct cdns_spi *xspi;
struct resource *res;
u32 num_cs; u32 num_cs;
master = spi_alloc_master(&pdev->dev, sizeof(*xspi)); master = spi_alloc_master(&pdev->dev, sizeof(*xspi));
...@@ -485,8 +484,7 @@ static int cdns_spi_probe(struct platform_device *pdev) ...@@ -485,8 +484,7 @@ static int cdns_spi_probe(struct platform_device *pdev)
master->dev.of_node = pdev->dev.of_node; master->dev.of_node = pdev->dev.of_node;
platform_set_drvdata(pdev, master); platform_set_drvdata(pdev, master);
res = platform_get_resource(pdev, IORESOURCE_MEM, 0); xspi->regs = devm_platform_ioremap_resource(pdev, 0);
xspi->regs = devm_ioremap_resource(&pdev->dev, res);
if (IS_ERR(xspi->regs)) { if (IS_ERR(xspi->regs)) {
ret = PTR_ERR(xspi->regs); ret = PTR_ERR(xspi->regs);
goto remove_master; goto remove_master;
...@@ -540,7 +538,6 @@ static int cdns_spi_probe(struct platform_device *pdev) ...@@ -540,7 +538,6 @@ static int cdns_spi_probe(struct platform_device *pdev)
irq = platform_get_irq(pdev, 0); irq = platform_get_irq(pdev, 0);
if (irq <= 0) { if (irq <= 0) {
ret = -ENXIO; ret = -ENXIO;
dev_err(&pdev->dev, "irq number is invalid\n");
goto clk_dis_all; goto clk_dis_all;
} }
......
...@@ -18,7 +18,6 @@ ...@@ -18,7 +18,6 @@
static int octeon_spi_probe(struct platform_device *pdev) static int octeon_spi_probe(struct platform_device *pdev)
{ {
struct resource *res_mem;
void __iomem *reg_base; void __iomem *reg_base;
struct spi_master *master; struct spi_master *master;
struct octeon_spi *p; struct octeon_spi *p;
...@@ -30,8 +29,7 @@ static int octeon_spi_probe(struct platform_device *pdev) ...@@ -30,8 +29,7 @@ static int octeon_spi_probe(struct platform_device *pdev)
p = spi_master_get_devdata(master); p = spi_master_get_devdata(master);
platform_set_drvdata(pdev, master); platform_set_drvdata(pdev, master);
res_mem = platform_get_resource(pdev, IORESOURCE_MEM, 0); reg_base = devm_platform_ioremap_resource(pdev, 0);
reg_base = devm_ioremap_resource(&pdev->dev, res_mem);
if (IS_ERR(reg_base)) { if (IS_ERR(reg_base)) {
err = PTR_ERR(reg_base); err = PTR_ERR(reg_base);
goto fail; goto fail;
......
...@@ -91,7 +91,6 @@ static int spi_clps711x_probe(struct platform_device *pdev) ...@@ -91,7 +91,6 @@ static int spi_clps711x_probe(struct platform_device *pdev)
{ {
struct spi_clps711x_data *hw; struct spi_clps711x_data *hw;
struct spi_master *master; struct spi_master *master;
struct resource *res;
int irq, ret; int irq, ret;
irq = platform_get_irq(pdev, 0); irq = platform_get_irq(pdev, 0);
...@@ -125,8 +124,7 @@ static int spi_clps711x_probe(struct platform_device *pdev) ...@@ -125,8 +124,7 @@ static int spi_clps711x_probe(struct platform_device *pdev)
goto err_out; goto err_out;
} }
res = platform_get_resource(pdev, IORESOURCE_MEM, 0); hw->syncio = devm_platform_ioremap_resource(pdev, 0);
hw->syncio = devm_ioremap_resource(&pdev->dev, res);
if (IS_ERR(hw->syncio)) { if (IS_ERR(hw->syncio)) {
ret = PTR_ERR(hw->syncio); ret = PTR_ERR(hw->syncio);
goto err_out; goto err_out;
......
...@@ -339,7 +339,6 @@ static int mcfqspi_probe(struct platform_device *pdev) ...@@ -339,7 +339,6 @@ static int mcfqspi_probe(struct platform_device *pdev)
{ {
struct spi_master *master; struct spi_master *master;
struct mcfqspi *mcfqspi; struct mcfqspi *mcfqspi;
struct resource *res;
struct mcfqspi_platform_data *pdata; struct mcfqspi_platform_data *pdata;
int status; int status;
...@@ -362,8 +361,7 @@ static int mcfqspi_probe(struct platform_device *pdev) ...@@ -362,8 +361,7 @@ static int mcfqspi_probe(struct platform_device *pdev)
mcfqspi = spi_master_get_devdata(master); mcfqspi = spi_master_get_devdata(master);
res = platform_get_resource(pdev, IORESOURCE_MEM, 0); mcfqspi->iobase = devm_platform_ioremap_resource(pdev, 0);
mcfqspi->iobase = devm_ioremap_resource(&pdev->dev, res);
if (IS_ERR(mcfqspi->iobase)) { if (IS_ERR(mcfqspi->iobase)) {
status = PTR_ERR(mcfqspi->iobase); status = PTR_ERR(mcfqspi->iobase);
goto fail0; goto fail0;
......
...@@ -79,14 +79,12 @@ static int dw_spi_mscc_init(struct platform_device *pdev, ...@@ -79,14 +79,12 @@ static int dw_spi_mscc_init(struct platform_device *pdev,
const char *cpu_syscon, u32 if_si_owner_offset) const char *cpu_syscon, u32 if_si_owner_offset)
{ {
struct dw_spi_mscc *dwsmscc; struct dw_spi_mscc *dwsmscc;
struct resource *res;
dwsmscc = devm_kzalloc(&pdev->dev, sizeof(*dwsmscc), GFP_KERNEL); dwsmscc = devm_kzalloc(&pdev->dev, sizeof(*dwsmscc), GFP_KERNEL);
if (!dwsmscc) if (!dwsmscc)
return -ENOMEM; return -ENOMEM;
res = platform_get_resource(pdev, IORESOURCE_MEM, 1); dwsmscc->spi_mst = devm_platform_ioremap_resource(pdev, 1);
dwsmscc->spi_mst = devm_ioremap_resource(&pdev->dev, res);
if (IS_ERR(dwsmscc->spi_mst)) { if (IS_ERR(dwsmscc->spi_mst)) {
dev_err(&pdev->dev, "SPI_MST region map failed\n"); dev_err(&pdev->dev, "SPI_MST region map failed\n");
return PTR_ERR(dwsmscc->spi_mst); return PTR_ERR(dwsmscc->spi_mst);
...@@ -138,7 +136,6 @@ static int dw_spi_mmio_probe(struct platform_device *pdev) ...@@ -138,7 +136,6 @@ static int dw_spi_mmio_probe(struct platform_device *pdev)
struct dw_spi_mmio *dwsmmio); struct dw_spi_mmio *dwsmmio);
struct dw_spi_mmio *dwsmmio; struct dw_spi_mmio *dwsmmio;
struct dw_spi *dws; struct dw_spi *dws;
struct resource *mem;
int ret; int ret;
int num_cs; int num_cs;
...@@ -150,18 +147,15 @@ static int dw_spi_mmio_probe(struct platform_device *pdev) ...@@ -150,18 +147,15 @@ static int dw_spi_mmio_probe(struct platform_device *pdev)
dws = &dwsmmio->dws; dws = &dwsmmio->dws;
/* Get basic io resource and map it */ /* Get basic io resource and map it */
mem = platform_get_resource(pdev, IORESOURCE_MEM, 0); dws->regs = devm_platform_ioremap_resource(pdev, 0);
dws->regs = devm_ioremap_resource(&pdev->dev, mem);
if (IS_ERR(dws->regs)) { if (IS_ERR(dws->regs)) {
dev_err(&pdev->dev, "SPI region map failed\n"); dev_err(&pdev->dev, "SPI region map failed\n");
return PTR_ERR(dws->regs); return PTR_ERR(dws->regs);
} }
dws->irq = platform_get_irq(pdev, 0); dws->irq = platform_get_irq(pdev, 0);
if (dws->irq < 0) { if (dws->irq < 0)
dev_err(&pdev->dev, "no irq resource?\n");
return dws->irq; /* -ENXIO */ return dws->irq; /* -ENXIO */
}
dwsmmio->clk = devm_clk_get(&pdev->dev, NULL); dwsmmio->clk = devm_clk_get(&pdev->dev, NULL);
if (IS_ERR(dwsmmio->clk)) if (IS_ERR(dwsmmio->clk))
...@@ -172,8 +166,10 @@ static int dw_spi_mmio_probe(struct platform_device *pdev) ...@@ -172,8 +166,10 @@ static int dw_spi_mmio_probe(struct platform_device *pdev)
/* Optional clock needed to access the registers */ /* Optional clock needed to access the registers */
dwsmmio->pclk = devm_clk_get_optional(&pdev->dev, "pclk"); dwsmmio->pclk = devm_clk_get_optional(&pdev->dev, "pclk");
if (IS_ERR(dwsmmio->pclk)) if (IS_ERR(dwsmmio->pclk)) {
return PTR_ERR(dwsmmio->pclk); ret = PTR_ERR(dwsmmio->pclk);
goto out_clk;
}
ret = clk_prepare_enable(dwsmmio->pclk); ret = clk_prepare_enable(dwsmmio->pclk);
if (ret) if (ret)
goto out_clk; goto out_clk;
......
...@@ -106,16 +106,14 @@ static void spi_pci_remove(struct pci_dev *pdev) ...@@ -106,16 +106,14 @@ static void spi_pci_remove(struct pci_dev *pdev)
#ifdef CONFIG_PM_SLEEP #ifdef CONFIG_PM_SLEEP
static int spi_suspend(struct device *dev) static int spi_suspend(struct device *dev)
{ {
struct pci_dev *pdev = to_pci_dev(dev); struct dw_spi *dws = dev_get_drvdata(dev);
struct dw_spi *dws = pci_get_drvdata(pdev);
return dw_spi_suspend_host(dws); return dw_spi_suspend_host(dws);
} }
static int spi_resume(struct device *dev) static int spi_resume(struct device *dev)
{ {
struct pci_dev *pdev = to_pci_dev(dev); struct dw_spi *dws = dev_get_drvdata(dev);
struct dw_spi *dws = pci_get_drvdata(pdev);
return dw_spi_resume_host(dws); return dw_spi_resume_host(dws);
} }
......
...@@ -400,10 +400,8 @@ static int efm32_spi_probe(struct platform_device *pdev) ...@@ -400,10 +400,8 @@ static int efm32_spi_probe(struct platform_device *pdev)
} }
ret = platform_get_irq(pdev, 0); ret = platform_get_irq(pdev, 0);
if (ret <= 0) { if (ret <= 0)
dev_err(&pdev->dev, "failed to get rx irq (%d)\n", ret);
goto err; goto err;
}
ddata->rxirq = ret; ddata->rxirq = ret;
......
...@@ -656,10 +656,8 @@ static int ep93xx_spi_probe(struct platform_device *pdev) ...@@ -656,10 +656,8 @@ static int ep93xx_spi_probe(struct platform_device *pdev)
} }
irq = platform_get_irq(pdev, 0); irq = platform_get_irq(pdev, 0);
if (irq < 0) { if (irq < 0)
dev_err(&pdev->dev, "failed to get irq resources\n");
return -EBUSY; return -EBUSY;
}
res = platform_get_resource(pdev, IORESOURCE_MEM, 0); res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
if (!res) { if (!res) {
......
...@@ -305,12 +305,10 @@ int fsl_spi_cpm_init(struct mpc8xxx_spi *mspi) ...@@ -305,12 +305,10 @@ int fsl_spi_cpm_init(struct mpc8xxx_spi *mspi)
} }
if (mspi->flags & SPI_CPM1) { if (mspi->flags & SPI_CPM1) {
struct resource *res;
void *pram; void *pram;
res = platform_get_resource(to_platform_device(dev), pram = devm_platform_ioremap_resource(to_platform_device(dev),
IORESOURCE_MEM, 1); 1);
pram = devm_ioremap_resource(dev, res);
if (IS_ERR(pram)) if (IS_ERR(pram))
mspi->pram = NULL; mspi->pram = NULL;
else else
......
This diff is collapsed.
...@@ -91,9 +91,6 @@ static inline u32 mpc8xxx_spi_read_reg(__be32 __iomem *reg) ...@@ -91,9 +91,6 @@ static inline u32 mpc8xxx_spi_read_reg(__be32 __iomem *reg)
struct mpc8xxx_spi_probe_info { struct mpc8xxx_spi_probe_info {
struct fsl_spi_platform_data pdata; struct fsl_spi_platform_data pdata;
int ngpios;
int *gpios;
bool *alow_flags;
__be32 __iomem *immr_spi_cs; __be32 __iomem *immr_spi_cs;
}; };
......
...@@ -860,10 +860,8 @@ static int fsl_qspi_probe(struct platform_device *pdev) ...@@ -860,10 +860,8 @@ static int fsl_qspi_probe(struct platform_device *pdev)
/* find the irq */ /* find the irq */
ret = platform_get_irq(pdev, 0); ret = platform_get_irq(pdev, 0);
if (ret < 0) { if (ret < 0)
dev_err(dev, "failed to get the irq: %d\n", ret);
goto err_disable_clk; goto err_disable_clk;
}
ret = devm_request_irq(dev, ret, ret = devm_request_irq(dev, ret,
fsl_qspi_irq_handler, 0, pdev->name, q); fsl_qspi_irq_handler, 0, pdev->name, q);
......
...@@ -18,7 +18,7 @@ ...@@ -18,7 +18,7 @@
#include <linux/delay.h> #include <linux/delay.h>
#include <linux/dma-mapping.h> #include <linux/dma-mapping.h>
#include <linux/fsl_devices.h> #include <linux/fsl_devices.h>
#include <linux/gpio.h> #include <linux/gpio/consumer.h>
#include <linux/interrupt.h> #include <linux/interrupt.h>
#include <linux/irq.h> #include <linux/irq.h>
#include <linux/kernel.h> #include <linux/kernel.h>
...@@ -28,7 +28,6 @@ ...@@ -28,7 +28,6 @@
#include <linux/of.h> #include <linux/of.h>
#include <linux/of_address.h> #include <linux/of_address.h>
#include <linux/of_irq.h> #include <linux/of_irq.h>
#include <linux/of_gpio.h>
#include <linux/of_platform.h> #include <linux/of_platform.h>
#include <linux/platform_device.h> #include <linux/platform_device.h>
#include <linux/spi/spi.h> #include <linux/spi/spi.h>
...@@ -481,32 +480,6 @@ static int fsl_spi_setup(struct spi_device *spi) ...@@ -481,32 +480,6 @@ static int fsl_spi_setup(struct spi_device *spi)
return retval; return retval;
} }
if (mpc8xxx_spi->type == TYPE_GRLIB) {
if (gpio_is_valid(spi->cs_gpio)) {
int desel;
retval = gpio_request(spi->cs_gpio,
dev_name(&spi->dev));
if (retval)
return retval;
desel = !(spi->mode & SPI_CS_HIGH);
retval = gpio_direction_output(spi->cs_gpio, desel);
if (retval) {
gpio_free(spi->cs_gpio);
return retval;
}
} else if (spi->cs_gpio != -ENOENT) {
if (spi->cs_gpio < 0)
return spi->cs_gpio;
return -EINVAL;
}
/* When spi->cs_gpio == -ENOENT, a hole in the phandle list
* indicates to use native chipselect if present, or allow for
* an always selected chip
*/
}
/* Initialize chipselect - might be active for SPI_CS_HIGH mode */ /* Initialize chipselect - might be active for SPI_CS_HIGH mode */
fsl_spi_chipselect(spi, BITBANG_CS_INACTIVE); fsl_spi_chipselect(spi, BITBANG_CS_INACTIVE);
...@@ -515,12 +488,8 @@ static int fsl_spi_setup(struct spi_device *spi) ...@@ -515,12 +488,8 @@ static int fsl_spi_setup(struct spi_device *spi)
static void fsl_spi_cleanup(struct spi_device *spi) static void fsl_spi_cleanup(struct spi_device *spi)
{ {
struct mpc8xxx_spi *mpc8xxx_spi = spi_master_get_devdata(spi->master);
struct spi_mpc8xxx_cs *cs = spi_get_ctldata(spi); struct spi_mpc8xxx_cs *cs = spi_get_ctldata(spi);
if (mpc8xxx_spi->type == TYPE_GRLIB && gpio_is_valid(spi->cs_gpio))
gpio_free(spi->cs_gpio);
kfree(cs); kfree(cs);
spi_set_ctldata(spi, NULL); spi_set_ctldata(spi, NULL);
} }
...@@ -586,8 +555,8 @@ static void fsl_spi_grlib_cs_control(struct spi_device *spi, bool on) ...@@ -586,8 +555,8 @@ static void fsl_spi_grlib_cs_control(struct spi_device *spi, bool on)
u32 slvsel; u32 slvsel;
u16 cs = spi->chip_select; u16 cs = spi->chip_select;
if (gpio_is_valid(spi->cs_gpio)) { if (spi->cs_gpiod) {
gpio_set_value(spi->cs_gpio, on); gpiod_set_value(spi->cs_gpiod, on);
} else if (cs < mpc8xxx_spi->native_chipselects) { } else if (cs < mpc8xxx_spi->native_chipselects) {
slvsel = mpc8xxx_spi_read_reg(&reg_base->slvsel); slvsel = mpc8xxx_spi_read_reg(&reg_base->slvsel);
slvsel = on ? (slvsel | (1 << cs)) : (slvsel & ~(1 << cs)); slvsel = on ? (slvsel | (1 << cs)) : (slvsel & ~(1 << cs));
...@@ -718,139 +687,19 @@ static struct spi_master * fsl_spi_probe(struct device *dev, ...@@ -718,139 +687,19 @@ static struct spi_master * fsl_spi_probe(struct device *dev,
static void fsl_spi_cs_control(struct spi_device *spi, bool on) static void fsl_spi_cs_control(struct spi_device *spi, bool on)
{ {
struct device *dev = spi->dev.parent->parent; if (spi->cs_gpiod) {
struct fsl_spi_platform_data *pdata = dev_get_platdata(dev); gpiod_set_value(spi->cs_gpiod, on);
struct mpc8xxx_spi_probe_info *pinfo = to_of_pinfo(pdata);
u16 cs = spi->chip_select;
if (cs < pinfo->ngpios) {
int gpio = pinfo->gpios[cs];
bool alow = pinfo->alow_flags[cs];
gpio_set_value(gpio, on ^ alow);
} else { } else {
if (WARN_ON_ONCE(cs > pinfo->ngpios || !pinfo->immr_spi_cs)) struct device *dev = spi->dev.parent->parent;
struct fsl_spi_platform_data *pdata = dev_get_platdata(dev);
struct mpc8xxx_spi_probe_info *pinfo = to_of_pinfo(pdata);
if (WARN_ON_ONCE(!pinfo->immr_spi_cs))
return; return;
iowrite32be(on ? SPI_BOOT_SEL_BIT : 0, pinfo->immr_spi_cs); iowrite32be(on ? SPI_BOOT_SEL_BIT : 0, pinfo->immr_spi_cs);
} }
} }
static int of_fsl_spi_get_chipselects(struct device *dev)
{
struct device_node *np = dev->of_node;
struct fsl_spi_platform_data *pdata = dev_get_platdata(dev);
struct mpc8xxx_spi_probe_info *pinfo = to_of_pinfo(pdata);
bool spisel_boot = IS_ENABLED(CONFIG_FSL_SOC) &&
of_property_read_bool(np, "fsl,spisel_boot");
int ngpios;
int i = 0;
int ret;
ngpios = of_gpio_count(np);
ngpios = max(ngpios, 0);
if (ngpios == 0 && !spisel_boot) {
/*
* SPI w/o chip-select line. One SPI device is still permitted
* though.
*/
pdata->max_chipselect = 1;
return 0;
}
pinfo->ngpios = ngpios;
pinfo->gpios = kmalloc_array(ngpios, sizeof(*pinfo->gpios),
GFP_KERNEL);
if (!pinfo->gpios)
return -ENOMEM;
memset(pinfo->gpios, -1, ngpios * sizeof(*pinfo->gpios));
pinfo->alow_flags = kcalloc(ngpios, sizeof(*pinfo->alow_flags),
GFP_KERNEL);
if (!pinfo->alow_flags) {
ret = -ENOMEM;
goto err_alloc_flags;
}
for (; i < ngpios; i++) {
int gpio;
enum of_gpio_flags flags;
gpio = of_get_gpio_flags(np, i, &flags);
if (!gpio_is_valid(gpio)) {
dev_err(dev, "invalid gpio #%d: %d\n", i, gpio);
ret = gpio;
goto err_loop;
}
ret = gpio_request(gpio, dev_name(dev));
if (ret) {
dev_err(dev, "can't request gpio #%d: %d\n", i, ret);
goto err_loop;
}
pinfo->gpios[i] = gpio;
pinfo->alow_flags[i] = flags & OF_GPIO_ACTIVE_LOW;
ret = gpio_direction_output(pinfo->gpios[i],
pinfo->alow_flags[i]);
if (ret) {
dev_err(dev,
"can't set output direction for gpio #%d: %d\n",
i, ret);
goto err_loop;
}
}
#if IS_ENABLED(CONFIG_FSL_SOC)
if (spisel_boot) {
pinfo->immr_spi_cs = ioremap(get_immrbase() + IMMR_SPI_CS_OFFSET, 4);
if (!pinfo->immr_spi_cs) {
ret = -ENOMEM;
i = ngpios - 1;
goto err_loop;
}
}
#endif
pdata->max_chipselect = ngpios + spisel_boot;
pdata->cs_control = fsl_spi_cs_control;
return 0;
err_loop:
while (i >= 0) {
if (gpio_is_valid(pinfo->gpios[i]))
gpio_free(pinfo->gpios[i]);
i--;
}
kfree(pinfo->alow_flags);
pinfo->alow_flags = NULL;
err_alloc_flags:
kfree(pinfo->gpios);
pinfo->gpios = NULL;
return ret;
}
static int of_fsl_spi_free_chipselects(struct device *dev)
{
struct fsl_spi_platform_data *pdata = dev_get_platdata(dev);
struct mpc8xxx_spi_probe_info *pinfo = to_of_pinfo(pdata);
int i;
if (!pinfo->gpios)
return 0;
for (i = 0; i < pdata->max_chipselect; i++) {
if (gpio_is_valid(pinfo->gpios[i]))
gpio_free(pinfo->gpios[i]);
}
kfree(pinfo->gpios);
kfree(pinfo->alow_flags);
return 0;
}
static int of_fsl_spi_probe(struct platform_device *ofdev) static int of_fsl_spi_probe(struct platform_device *ofdev)
{ {
struct device *dev = &ofdev->dev; struct device *dev = &ofdev->dev;
...@@ -866,9 +715,21 @@ static int of_fsl_spi_probe(struct platform_device *ofdev) ...@@ -866,9 +715,21 @@ static int of_fsl_spi_probe(struct platform_device *ofdev)
type = fsl_spi_get_type(&ofdev->dev); type = fsl_spi_get_type(&ofdev->dev);
if (type == TYPE_FSL) { if (type == TYPE_FSL) {
ret = of_fsl_spi_get_chipselects(dev); struct fsl_spi_platform_data *pdata = dev_get_platdata(dev);
if (ret) #if IS_ENABLED(CONFIG_FSL_SOC)
goto err; struct mpc8xxx_spi_probe_info *pinfo = to_of_pinfo(pdata);
bool spisel_boot = of_property_read_bool(np, "fsl,spisel_boot");
if (spisel_boot) {
pinfo->immr_spi_cs = ioremap(get_immrbase() + IMMR_SPI_CS_OFFSET, 4);
if (!pinfo->immr_spi_cs) {
ret = -ENOMEM;
goto err;
}
}
#endif
pdata->cs_control = fsl_spi_cs_control;
} }
ret = of_address_to_resource(np, 0, &mem); ret = of_address_to_resource(np, 0, &mem);
...@@ -891,8 +752,6 @@ static int of_fsl_spi_probe(struct platform_device *ofdev) ...@@ -891,8 +752,6 @@ static int of_fsl_spi_probe(struct platform_device *ofdev)
err: err:
irq_dispose_mapping(irq); irq_dispose_mapping(irq);
if (type == TYPE_FSL)
of_fsl_spi_free_chipselects(dev);
return ret; return ret;
} }
...@@ -902,8 +761,6 @@ static int of_fsl_spi_remove(struct platform_device *ofdev) ...@@ -902,8 +761,6 @@ static int of_fsl_spi_remove(struct platform_device *ofdev)
struct mpc8xxx_spi *mpc8xxx_spi = spi_master_get_devdata(master); struct mpc8xxx_spi *mpc8xxx_spi = spi_master_get_devdata(master);
fsl_spi_cpm_free(mpc8xxx_spi); fsl_spi_cpm_free(mpc8xxx_spi);
if (mpc8xxx_spi->type == TYPE_FSL)
of_fsl_spi_free_chipselects(&ofdev->dev);
return 0; return 0;
} }
......
...@@ -534,18 +534,14 @@ static int spi_geni_probe(struct platform_device *pdev) ...@@ -534,18 +534,14 @@ static int spi_geni_probe(struct platform_device *pdev)
int ret, irq; int ret, irq;
struct spi_master *spi; struct spi_master *spi;
struct spi_geni_master *mas; struct spi_geni_master *mas;
struct resource *res;
void __iomem *base; void __iomem *base;
struct clk *clk; struct clk *clk;
irq = platform_get_irq(pdev, 0); irq = platform_get_irq(pdev, 0);
if (irq < 0) { if (irq < 0)
dev_err(&pdev->dev, "Err getting IRQ %d\n", irq);
return irq; return irq;
}
res = platform_get_resource(pdev, IORESOURCE_MEM, 0); base = devm_platform_ioremap_resource(pdev, 0);
base = devm_ioremap_resource(&pdev->dev, res);
if (IS_ERR(base)) if (IS_ERR(base))
return PTR_ERR(base); return PTR_ERR(base);
......
...@@ -290,10 +290,7 @@ static int spi_gpio_request(struct device *dev, struct spi_gpio *spi_gpio) ...@@ -290,10 +290,7 @@ static int spi_gpio_request(struct device *dev, struct spi_gpio *spi_gpio)
return PTR_ERR(spi_gpio->miso); return PTR_ERR(spi_gpio->miso);
spi_gpio->sck = devm_gpiod_get(dev, "sck", GPIOD_OUT_LOW); spi_gpio->sck = devm_gpiod_get(dev, "sck", GPIOD_OUT_LOW);
if (IS_ERR(spi_gpio->sck)) return PTR_ERR_OR_ZERO(spi_gpio->sck);
return PTR_ERR(spi_gpio->sck);
return 0;
} }
#ifdef CONFIG_OF #ifdef CONFIG_OF
......
...@@ -819,22 +819,16 @@ static int lantiq_ssc_probe(struct platform_device *pdev) ...@@ -819,22 +819,16 @@ static int lantiq_ssc_probe(struct platform_device *pdev)
} }
rx_irq = platform_get_irq_byname(pdev, LTQ_SPI_RX_IRQ_NAME); rx_irq = platform_get_irq_byname(pdev, LTQ_SPI_RX_IRQ_NAME);
if (rx_irq < 0) { if (rx_irq < 0)
dev_err(dev, "failed to get %s\n", LTQ_SPI_RX_IRQ_NAME);
return -ENXIO; return -ENXIO;
}
tx_irq = platform_get_irq_byname(pdev, LTQ_SPI_TX_IRQ_NAME); tx_irq = platform_get_irq_byname(pdev, LTQ_SPI_TX_IRQ_NAME);
if (tx_irq < 0) { if (tx_irq < 0)
dev_err(dev, "failed to get %s\n", LTQ_SPI_TX_IRQ_NAME);
return -ENXIO; return -ENXIO;
}
err_irq = platform_get_irq_byname(pdev, LTQ_SPI_ERR_IRQ_NAME); err_irq = platform_get_irq_byname(pdev, LTQ_SPI_ERR_IRQ_NAME);
if (err_irq < 0) { if (err_irq < 0)
dev_err(dev, "failed to get %s\n", LTQ_SPI_ERR_IRQ_NAME);
return -ENXIO; return -ENXIO;
}
master = spi_alloc_master(dev, sizeof(struct lantiq_ssc_spi)); master = spi_alloc_master(dev, sizeof(struct lantiq_ssc_spi));
if (!master) if (!master)
......
...@@ -185,7 +185,6 @@ spi_lp8841_rtc_probe(struct platform_device *pdev) ...@@ -185,7 +185,6 @@ spi_lp8841_rtc_probe(struct platform_device *pdev)
int ret; int ret;
struct spi_master *master; struct spi_master *master;
struct spi_lp8841_rtc *data; struct spi_lp8841_rtc *data;
void *iomem;
master = spi_alloc_master(&pdev->dev, sizeof(*data)); master = spi_alloc_master(&pdev->dev, sizeof(*data));
if (!master) if (!master)
...@@ -207,8 +206,7 @@ spi_lp8841_rtc_probe(struct platform_device *pdev) ...@@ -207,8 +206,7 @@ spi_lp8841_rtc_probe(struct platform_device *pdev)
data = spi_master_get_devdata(master); data = spi_master_get_devdata(master);
iomem = platform_get_resource(pdev, IORESOURCE_MEM, 0); data->iomem = devm_platform_ioremap_resource(pdev, 0);
data->iomem = devm_ioremap_resource(&pdev->dev, iomem);
ret = PTR_ERR_OR_ZERO(data->iomem); ret = PTR_ERR_OR_ZERO(data->iomem);
if (ret) { if (ret) {
dev_err(&pdev->dev, "failed to get IO address\n"); dev_err(&pdev->dev, "failed to get IO address\n");
......
...@@ -503,7 +503,6 @@ static int meson_spicc_probe(struct platform_device *pdev) ...@@ -503,7 +503,6 @@ static int meson_spicc_probe(struct platform_device *pdev)
{ {
struct spi_master *master; struct spi_master *master;
struct meson_spicc_device *spicc; struct meson_spicc_device *spicc;
struct resource *res;
int ret, irq, rate; int ret, irq, rate;
master = spi_alloc_master(&pdev->dev, sizeof(*spicc)); master = spi_alloc_master(&pdev->dev, sizeof(*spicc));
...@@ -517,8 +516,7 @@ static int meson_spicc_probe(struct platform_device *pdev) ...@@ -517,8 +516,7 @@ static int meson_spicc_probe(struct platform_device *pdev)
spicc->pdev = pdev; spicc->pdev = pdev;
platform_set_drvdata(pdev, spicc); platform_set_drvdata(pdev, spicc);
res = platform_get_resource(pdev, IORESOURCE_MEM, 0); spicc->base = devm_platform_ioremap_resource(pdev, 0);
spicc->base = devm_ioremap_resource(&pdev->dev, res);
if (IS_ERR(spicc->base)) { if (IS_ERR(spicc->base)) {
dev_err(&pdev->dev, "io resource mapping failed\n"); dev_err(&pdev->dev, "io resource mapping failed\n");
ret = PTR_ERR(spicc->base); ret = PTR_ERR(spicc->base);
......
...@@ -286,7 +286,6 @@ static int meson_spifc_probe(struct platform_device *pdev) ...@@ -286,7 +286,6 @@ static int meson_spifc_probe(struct platform_device *pdev)
{ {
struct spi_master *master; struct spi_master *master;
struct meson_spifc *spifc; struct meson_spifc *spifc;
struct resource *res;
void __iomem *base; void __iomem *base;
unsigned int rate; unsigned int rate;
int ret = 0; int ret = 0;
...@@ -300,8 +299,7 @@ static int meson_spifc_probe(struct platform_device *pdev) ...@@ -300,8 +299,7 @@ static int meson_spifc_probe(struct platform_device *pdev)
spifc = spi_master_get_devdata(master); spifc = spi_master_get_devdata(master);
spifc->dev = &pdev->dev; spifc->dev = &pdev->dev;
res = platform_get_resource(pdev, IORESOURCE_MEM, 0); base = devm_platform_ioremap_resource(pdev, 0);
base = devm_ioremap_resource(spifc->dev, res);
if (IS_ERR(base)) { if (IS_ERR(base)) {
ret = PTR_ERR(base); ret = PTR_ERR(base);
goto out_err; goto out_err;
......
...@@ -17,6 +17,7 @@ ...@@ -17,6 +17,7 @@
#include <linux/platform_data/spi-mt65xx.h> #include <linux/platform_data/spi-mt65xx.h>
#include <linux/pm_runtime.h> #include <linux/pm_runtime.h>
#include <linux/spi/spi.h> #include <linux/spi/spi.h>
#include <linux/dma-mapping.h>
#define SPI_CFG0_REG 0x0000 #define SPI_CFG0_REG 0x0000
#define SPI_CFG1_REG 0x0004 #define SPI_CFG1_REG 0x0004
...@@ -28,6 +29,8 @@ ...@@ -28,6 +29,8 @@
#define SPI_STATUS0_REG 0x001c #define SPI_STATUS0_REG 0x001c
#define SPI_PAD_SEL_REG 0x0024 #define SPI_PAD_SEL_REG 0x0024
#define SPI_CFG2_REG 0x0028 #define SPI_CFG2_REG 0x0028
#define SPI_TX_SRC_REG_64 0x002c
#define SPI_RX_DST_REG_64 0x0030
#define SPI_CFG0_SCK_HIGH_OFFSET 0 #define SPI_CFG0_SCK_HIGH_OFFSET 0
#define SPI_CFG0_SCK_LOW_OFFSET 8 #define SPI_CFG0_SCK_LOW_OFFSET 8
...@@ -73,6 +76,10 @@ ...@@ -73,6 +76,10 @@
#define MTK_SPI_MAX_FIFO_SIZE 32U #define MTK_SPI_MAX_FIFO_SIZE 32U
#define MTK_SPI_PACKET_SIZE 1024 #define MTK_SPI_PACKET_SIZE 1024
#define MTK_SPI_32BITS_MASK (0xffffffff)
#define DMA_ADDR_EXT_BITS (36)
#define DMA_ADDR_DEF_BITS (32)
struct mtk_spi_compatible { struct mtk_spi_compatible {
bool need_pad_sel; bool need_pad_sel;
...@@ -80,6 +87,8 @@ struct mtk_spi_compatible { ...@@ -80,6 +87,8 @@ struct mtk_spi_compatible {
bool must_tx; bool must_tx;
/* some IC design adjust cfg register to enhance time accuracy */ /* some IC design adjust cfg register to enhance time accuracy */
bool enhance_timing; bool enhance_timing;
/* some IC support DMA addr extension */
bool dma_ext;
}; };
struct mtk_spi { struct mtk_spi {
...@@ -102,6 +111,13 @@ static const struct mtk_spi_compatible mt2712_compat = { ...@@ -102,6 +111,13 @@ static const struct mtk_spi_compatible mt2712_compat = {
.must_tx = true, .must_tx = true,
}; };
static const struct mtk_spi_compatible mt6765_compat = {
.need_pad_sel = true,
.must_tx = true,
.enhance_timing = true,
.dma_ext = true,
};
static const struct mtk_spi_compatible mt7622_compat = { static const struct mtk_spi_compatible mt7622_compat = {
.must_tx = true, .must_tx = true,
.enhance_timing = true, .enhance_timing = true,
...@@ -137,6 +153,9 @@ static const struct of_device_id mtk_spi_of_match[] = { ...@@ -137,6 +153,9 @@ static const struct of_device_id mtk_spi_of_match[] = {
{ .compatible = "mediatek,mt6589-spi", { .compatible = "mediatek,mt6589-spi",
.data = (void *)&mtk_common_compat, .data = (void *)&mtk_common_compat,
}, },
{ .compatible = "mediatek,mt6765-spi",
.data = (void *)&mt6765_compat,
},
{ .compatible = "mediatek,mt7622-spi", { .compatible = "mediatek,mt7622-spi",
.data = (void *)&mt7622_compat, .data = (void *)&mt7622_compat,
}, },
...@@ -371,10 +390,25 @@ static void mtk_spi_setup_dma_addr(struct spi_master *master, ...@@ -371,10 +390,25 @@ static void mtk_spi_setup_dma_addr(struct spi_master *master,
{ {
struct mtk_spi *mdata = spi_master_get_devdata(master); struct mtk_spi *mdata = spi_master_get_devdata(master);
if (mdata->tx_sgl) if (mdata->tx_sgl) {
writel(xfer->tx_dma, mdata->base + SPI_TX_SRC_REG); writel((u32)(xfer->tx_dma & MTK_SPI_32BITS_MASK),
if (mdata->rx_sgl) mdata->base + SPI_TX_SRC_REG);
writel(xfer->rx_dma, mdata->base + SPI_RX_DST_REG); #ifdef CONFIG_ARCH_DMA_ADDR_T_64BIT
if (mdata->dev_comp->dma_ext)
writel((u32)(xfer->tx_dma >> 32),
mdata->base + SPI_TX_SRC_REG_64);
#endif
}
if (mdata->rx_sgl) {
writel((u32)(xfer->rx_dma & MTK_SPI_32BITS_MASK),
mdata->base + SPI_RX_DST_REG);
#ifdef CONFIG_ARCH_DMA_ADDR_T_64BIT
if (mdata->dev_comp->dma_ext)
writel((u32)(xfer->rx_dma >> 32),
mdata->base + SPI_RX_DST_REG_64);
#endif
}
} }
static int mtk_spi_fifo_transfer(struct spi_master *master, static int mtk_spi_fifo_transfer(struct spi_master *master,
...@@ -586,7 +620,7 @@ static int mtk_spi_probe(struct platform_device *pdev) ...@@ -586,7 +620,7 @@ static int mtk_spi_probe(struct platform_device *pdev)
struct mtk_spi *mdata; struct mtk_spi *mdata;
const struct of_device_id *of_id; const struct of_device_id *of_id;
struct resource *res; struct resource *res;
int i, irq, ret; int i, irq, ret, addr_bits;
master = spi_alloc_master(&pdev->dev, sizeof(*mdata)); master = spi_alloc_master(&pdev->dev, sizeof(*mdata));
if (!master) { if (!master) {
...@@ -664,7 +698,6 @@ static int mtk_spi_probe(struct platform_device *pdev) ...@@ -664,7 +698,6 @@ static int mtk_spi_probe(struct platform_device *pdev)
irq = platform_get_irq(pdev, 0); irq = platform_get_irq(pdev, 0);
if (irq < 0) { if (irq < 0) {
dev_err(&pdev->dev, "failed to get irq (%d)\n", irq);
ret = irq; ret = irq;
goto err_put_master; goto err_put_master;
} }
...@@ -753,6 +786,15 @@ static int mtk_spi_probe(struct platform_device *pdev) ...@@ -753,6 +786,15 @@ static int mtk_spi_probe(struct platform_device *pdev)
} }
} }
if (mdata->dev_comp->dma_ext)
addr_bits = DMA_ADDR_EXT_BITS;
else
addr_bits = DMA_ADDR_DEF_BITS;
ret = dma_set_mask(&pdev->dev, DMA_BIT_MASK(addr_bits));
if (ret)
dev_notice(&pdev->dev, "SPI dma_set_mask(%d) failed, ret:%d\n",
addr_bits, ret);
return 0; return 0;
err_disable_runtime_pm: err_disable_runtime_pm:
......
...@@ -327,7 +327,6 @@ static int mt7621_spi_probe(struct platform_device *pdev) ...@@ -327,7 +327,6 @@ static int mt7621_spi_probe(struct platform_device *pdev)
struct spi_controller *master; struct spi_controller *master;
struct mt7621_spi *rs; struct mt7621_spi *rs;
void __iomem *base; void __iomem *base;
struct resource *r;
int status = 0; int status = 0;
struct clk *clk; struct clk *clk;
int ret; int ret;
...@@ -336,8 +335,7 @@ static int mt7621_spi_probe(struct platform_device *pdev) ...@@ -336,8 +335,7 @@ static int mt7621_spi_probe(struct platform_device *pdev)
if (!match) if (!match)
return -EINVAL; return -EINVAL;
r = platform_get_resource(pdev, IORESOURCE_MEM, 0); base = devm_platform_ioremap_resource(pdev, 0);
base = devm_ioremap_resource(&pdev->dev, r);
if (IS_ERR(base)) if (IS_ERR(base))
return PTR_ERR(base); return PTR_ERR(base);
......
...@@ -532,7 +532,6 @@ static int mxs_spi_probe(struct platform_device *pdev) ...@@ -532,7 +532,6 @@ static int mxs_spi_probe(struct platform_device *pdev)
struct spi_master *master; struct spi_master *master;
struct mxs_spi *spi; struct mxs_spi *spi;
struct mxs_ssp *ssp; struct mxs_ssp *ssp;
struct resource *iores;
struct clk *clk; struct clk *clk;
void __iomem *base; void __iomem *base;
int devid, clk_freq; int devid, clk_freq;
...@@ -545,12 +544,11 @@ static int mxs_spi_probe(struct platform_device *pdev) ...@@ -545,12 +544,11 @@ static int mxs_spi_probe(struct platform_device *pdev)
*/ */
const int clk_freq_default = 160000000; const int clk_freq_default = 160000000;
iores = platform_get_resource(pdev, IORESOURCE_MEM, 0);
irq_err = platform_get_irq(pdev, 0); irq_err = platform_get_irq(pdev, 0);
if (irq_err < 0) if (irq_err < 0)
return irq_err; return irq_err;
base = devm_ioremap_resource(&pdev->dev, iores); base = devm_platform_ioremap_resource(pdev, 0);
if (IS_ERR(base)) if (IS_ERR(base))
return PTR_ERR(base); return PTR_ERR(base);
......
This diff is collapsed.
...@@ -341,7 +341,6 @@ static int npcm_pspi_probe(struct platform_device *pdev) ...@@ -341,7 +341,6 @@ static int npcm_pspi_probe(struct platform_device *pdev)
{ {
struct npcm_pspi *priv; struct npcm_pspi *priv;
struct spi_master *master; struct spi_master *master;
struct resource *res;
unsigned long clk_hz; unsigned long clk_hz;
struct device_node *np = pdev->dev.of_node; struct device_node *np = pdev->dev.of_node;
int num_cs, i; int num_cs, i;
...@@ -368,8 +367,7 @@ static int npcm_pspi_probe(struct platform_device *pdev) ...@@ -368,8 +367,7 @@ static int npcm_pspi_probe(struct platform_device *pdev)
priv->is_save_param = false; priv->is_save_param = false;
priv->id = pdev->id; priv->id = pdev->id;
res = platform_get_resource(pdev, IORESOURCE_MEM, 0); priv->base = devm_platform_ioremap_resource(pdev, 0);
priv->base = devm_ioremap_resource(&pdev->dev, res);
if (IS_ERR(priv->base)) { if (IS_ERR(priv->base)) {
ret = PTR_ERR(priv->base); ret = PTR_ERR(priv->base);
goto out_master_put; goto out_master_put;
...@@ -388,7 +386,6 @@ static int npcm_pspi_probe(struct platform_device *pdev) ...@@ -388,7 +386,6 @@ static int npcm_pspi_probe(struct platform_device *pdev)
irq = platform_get_irq(pdev, 0); irq = platform_get_irq(pdev, 0);
if (irq < 0) { if (irq < 0) {
dev_err(&pdev->dev, "failed to get IRQ\n");
ret = irq; ret = irq;
goto out_disable_clk; goto out_disable_clk;
} }
......
...@@ -327,7 +327,6 @@ static int nuc900_spi_probe(struct platform_device *pdev) ...@@ -327,7 +327,6 @@ static int nuc900_spi_probe(struct platform_device *pdev)
{ {
struct nuc900_spi *hw; struct nuc900_spi *hw;
struct spi_master *master; struct spi_master *master;
struct resource *res;
int err = 0; int err = 0;
master = spi_alloc_master(&pdev->dev, sizeof(struct nuc900_spi)); master = spi_alloc_master(&pdev->dev, sizeof(struct nuc900_spi));
...@@ -358,8 +357,7 @@ static int nuc900_spi_probe(struct platform_device *pdev) ...@@ -358,8 +357,7 @@ static int nuc900_spi_probe(struct platform_device *pdev)
hw->bitbang.chipselect = nuc900_spi_chipsel; hw->bitbang.chipselect = nuc900_spi_chipsel;
hw->bitbang.txrx_bufs = nuc900_spi_txrx; hw->bitbang.txrx_bufs = nuc900_spi_txrx;
res = platform_get_resource(pdev, IORESOURCE_MEM, 0); hw->regs = devm_platform_ioremap_resource(pdev, 0);
hw->regs = devm_ioremap_resource(&pdev->dev, res);
if (IS_ERR(hw->regs)) { if (IS_ERR(hw->regs)) {
err = PTR_ERR(hw->regs); err = PTR_ERR(hw->regs);
goto err_pdata; goto err_pdata;
...@@ -367,7 +365,6 @@ static int nuc900_spi_probe(struct platform_device *pdev) ...@@ -367,7 +365,6 @@ static int nuc900_spi_probe(struct platform_device *pdev)
hw->irq = platform_get_irq(pdev, 0); hw->irq = platform_get_irq(pdev, 0);
if (hw->irq < 0) { if (hw->irq < 0) {
dev_err(&pdev->dev, "No IRQ specified\n");
err = -ENOENT; err = -ENOENT;
goto err_pdata; goto err_pdata;
} }
......
...@@ -1007,10 +1007,8 @@ static int nxp_fspi_probe(struct platform_device *pdev) ...@@ -1007,10 +1007,8 @@ static int nxp_fspi_probe(struct platform_device *pdev)
/* find the irq */ /* find the irq */
ret = platform_get_irq(pdev, 0); ret = platform_get_irq(pdev, 0);
if (ret < 0) { if (ret < 0)
dev_err(dev, "failed to get the irq: %d\n", ret);
goto err_disable_clk; goto err_disable_clk;
}
ret = devm_request_irq(dev, ret, ret = devm_request_irq(dev, ret,
nxp_fspi_irq_handler, 0, pdev->name, f); nxp_fspi_irq_handler, 0, pdev->name, f);
......
...@@ -240,7 +240,6 @@ static int tiny_spi_probe(struct platform_device *pdev) ...@@ -240,7 +240,6 @@ static int tiny_spi_probe(struct platform_device *pdev)
struct tiny_spi_platform_data *platp = dev_get_platdata(&pdev->dev); struct tiny_spi_platform_data *platp = dev_get_platdata(&pdev->dev);
struct tiny_spi *hw; struct tiny_spi *hw;
struct spi_master *master; struct spi_master *master;
struct resource *res;
unsigned int i; unsigned int i;
int err = -ENODEV; int err = -ENODEV;
...@@ -264,8 +263,7 @@ static int tiny_spi_probe(struct platform_device *pdev) ...@@ -264,8 +263,7 @@ static int tiny_spi_probe(struct platform_device *pdev)
hw->bitbang.txrx_bufs = tiny_spi_txrx_bufs; hw->bitbang.txrx_bufs = tiny_spi_txrx_bufs;
/* find and map our resources */ /* find and map our resources */
res = platform_get_resource(pdev, IORESOURCE_MEM, 0); hw->base = devm_platform_ioremap_resource(pdev, 0);
hw->base = devm_ioremap_resource(&pdev->dev, res);
if (IS_ERR(hw->base)) { if (IS_ERR(hw->base)) {
err = PTR_ERR(hw->base); err = PTR_ERR(hw->base);
goto exit; goto exit;
......
...@@ -570,7 +570,6 @@ static int pic32_sqi_probe(struct platform_device *pdev) ...@@ -570,7 +570,6 @@ static int pic32_sqi_probe(struct platform_device *pdev)
{ {
struct spi_master *master; struct spi_master *master;
struct pic32_sqi *sqi; struct pic32_sqi *sqi;
struct resource *reg;
int ret; int ret;
master = spi_alloc_master(&pdev->dev, sizeof(*sqi)); master = spi_alloc_master(&pdev->dev, sizeof(*sqi));
...@@ -580,8 +579,7 @@ static int pic32_sqi_probe(struct platform_device *pdev) ...@@ -580,8 +579,7 @@ static int pic32_sqi_probe(struct platform_device *pdev)
sqi = spi_master_get_devdata(master); sqi = spi_master_get_devdata(master);
sqi->master = master; sqi->master = master;
reg = platform_get_resource(pdev, IORESOURCE_MEM, 0); sqi->regs = devm_platform_ioremap_resource(pdev, 0);
sqi->regs = devm_ioremap_resource(&pdev->dev, reg);
if (IS_ERR(sqi->regs)) { if (IS_ERR(sqi->regs)) {
ret = PTR_ERR(sqi->regs); ret = PTR_ERR(sqi->regs);
goto err_free_master; goto err_free_master;
...@@ -590,7 +588,6 @@ static int pic32_sqi_probe(struct platform_device *pdev) ...@@ -590,7 +588,6 @@ static int pic32_sqi_probe(struct platform_device *pdev)
/* irq */ /* irq */
sqi->irq = platform_get_irq(pdev, 0); sqi->irq = platform_get_irq(pdev, 0);
if (sqi->irq < 0) { if (sqi->irq < 0) {
dev_err(&pdev->dev, "no irq found\n");
ret = sqi->irq; ret = sqi->irq;
goto err_free_master; goto err_free_master;
} }
......
...@@ -711,22 +711,16 @@ static int pic32_spi_hw_probe(struct platform_device *pdev, ...@@ -711,22 +711,16 @@ static int pic32_spi_hw_probe(struct platform_device *pdev,
/* get irq resources: err-irq, rx-irq, tx-irq */ /* get irq resources: err-irq, rx-irq, tx-irq */
pic32s->fault_irq = platform_get_irq_byname(pdev, "fault"); pic32s->fault_irq = platform_get_irq_byname(pdev, "fault");
if (pic32s->fault_irq < 0) { if (pic32s->fault_irq < 0)
dev_err(&pdev->dev, "fault-irq not found\n");
return pic32s->fault_irq; return pic32s->fault_irq;
}
pic32s->rx_irq = platform_get_irq_byname(pdev, "rx"); pic32s->rx_irq = platform_get_irq_byname(pdev, "rx");
if (pic32s->rx_irq < 0) { if (pic32s->rx_irq < 0)
dev_err(&pdev->dev, "rx-irq not found\n");
return pic32s->rx_irq; return pic32s->rx_irq;
}
pic32s->tx_irq = platform_get_irq_byname(pdev, "tx"); pic32s->tx_irq = platform_get_irq_byname(pdev, "tx");
if (pic32s->tx_irq < 0) { if (pic32s->tx_irq < 0)
dev_err(&pdev->dev, "tx-irq not found\n");
return pic32s->tx_irq; return pic32s->tx_irq;
}
/* get clock */ /* get clock */
pic32s->clk = devm_clk_get(&pdev->dev, "mck0"); pic32s->clk = devm_clk_get(&pdev->dev, "mck0");
......
...@@ -424,7 +424,6 @@ static int qcom_qspi_probe(struct platform_device *pdev) ...@@ -424,7 +424,6 @@ static int qcom_qspi_probe(struct platform_device *pdev)
{ {
int ret; int ret;
struct device *dev; struct device *dev;
struct resource *res;
struct spi_master *master; struct spi_master *master;
struct qcom_qspi *ctrl; struct qcom_qspi *ctrl;
...@@ -440,8 +439,7 @@ static int qcom_qspi_probe(struct platform_device *pdev) ...@@ -440,8 +439,7 @@ static int qcom_qspi_probe(struct platform_device *pdev)
spin_lock_init(&ctrl->lock); spin_lock_init(&ctrl->lock);
ctrl->dev = dev; ctrl->dev = dev;
res = platform_get_resource(pdev, IORESOURCE_MEM, 0); ctrl->base = devm_platform_ioremap_resource(pdev, 0);
ctrl->base = devm_ioremap_resource(dev, res);
if (IS_ERR(ctrl->base)) { if (IS_ERR(ctrl->base)) {
ret = PTR_ERR(ctrl->base); ret = PTR_ERR(ctrl->base);
goto exit_probe_master_put; goto exit_probe_master_put;
...@@ -454,10 +452,8 @@ static int qcom_qspi_probe(struct platform_device *pdev) ...@@ -454,10 +452,8 @@ static int qcom_qspi_probe(struct platform_device *pdev)
goto exit_probe_master_put; goto exit_probe_master_put;
ret = platform_get_irq(pdev, 0); ret = platform_get_irq(pdev, 0);
if (ret < 0) { if (ret < 0)
dev_err(dev, "Failed to get irq %d\n", ret);
goto exit_probe_master_put; goto exit_probe_master_put;
}
ret = devm_request_irq(dev, ret, qcom_qspi_irq, ret = devm_request_irq(dev, ret, qcom_qspi_irq,
IRQF_TRIGGER_HIGH, dev_name(dev), ctrl); IRQF_TRIGGER_HIGH, dev_name(dev), ctrl);
if (ret) { if (ret) {
......
...@@ -135,12 +135,10 @@ static int rb4xx_spi_probe(struct platform_device *pdev) ...@@ -135,12 +135,10 @@ static int rb4xx_spi_probe(struct platform_device *pdev)
struct spi_master *master; struct spi_master *master;
struct clk *ahb_clk; struct clk *ahb_clk;
struct rb4xx_spi *rbspi; struct rb4xx_spi *rbspi;
struct resource *r;
int err; int err;
void __iomem *spi_base; void __iomem *spi_base;
r = platform_get_resource(pdev, IORESOURCE_MEM, 0); spi_base = devm_platform_ioremap_resource(pdev, 0);
spi_base = devm_ioremap_resource(&pdev->dev, r);
if (IS_ERR(spi_base)) if (IS_ERR(spi_base))
return PTR_ERR(spi_base); return PTR_ERR(spi_base);
......
...@@ -487,7 +487,6 @@ static int s3c24xx_spi_probe(struct platform_device *pdev) ...@@ -487,7 +487,6 @@ static int s3c24xx_spi_probe(struct platform_device *pdev)
struct s3c2410_spi_info *pdata; struct s3c2410_spi_info *pdata;
struct s3c24xx_spi *hw; struct s3c24xx_spi *hw;
struct spi_master *master; struct spi_master *master;
struct resource *res;
int err = 0; int err = 0;
master = spi_alloc_master(&pdev->dev, sizeof(struct s3c24xx_spi)); master = spi_alloc_master(&pdev->dev, sizeof(struct s3c24xx_spi));
...@@ -536,8 +535,7 @@ static int s3c24xx_spi_probe(struct platform_device *pdev) ...@@ -536,8 +535,7 @@ static int s3c24xx_spi_probe(struct platform_device *pdev)
dev_dbg(hw->dev, "bitbang at %p\n", &hw->bitbang); dev_dbg(hw->dev, "bitbang at %p\n", &hw->bitbang);
/* find and map our resources */ /* find and map our resources */
res = platform_get_resource(pdev, IORESOURCE_MEM, 0); hw->regs = devm_platform_ioremap_resource(pdev, 0);
hw->regs = devm_ioremap_resource(&pdev->dev, res);
if (IS_ERR(hw->regs)) { if (IS_ERR(hw->regs)) {
err = PTR_ERR(hw->regs); err = PTR_ERR(hw->regs);
goto err_no_pdata; goto err_no_pdata;
...@@ -545,7 +543,6 @@ static int s3c24xx_spi_probe(struct platform_device *pdev) ...@@ -545,7 +543,6 @@ static int s3c24xx_spi_probe(struct platform_device *pdev)
hw->irq = platform_get_irq(pdev, 0); hw->irq = platform_get_irq(pdev, 0);
if (hw->irq < 0) { if (hw->irq < 0) {
dev_err(&pdev->dev, "No IRQ specified\n");
err = -ENOENT; err = -ENOENT;
goto err_no_pdata; goto err_no_pdata;
} }
......
...@@ -1297,7 +1297,6 @@ static void sh_msiof_release_dma(struct sh_msiof_spi_priv *p) ...@@ -1297,7 +1297,6 @@ static void sh_msiof_release_dma(struct sh_msiof_spi_priv *p)
static int sh_msiof_spi_probe(struct platform_device *pdev) static int sh_msiof_spi_probe(struct platform_device *pdev)
{ {
struct resource *r;
struct spi_controller *ctlr; struct spi_controller *ctlr;
const struct sh_msiof_chipdata *chipdata; const struct sh_msiof_chipdata *chipdata;
struct sh_msiof_spi_info *info; struct sh_msiof_spi_info *info;
...@@ -1346,13 +1345,11 @@ static int sh_msiof_spi_probe(struct platform_device *pdev) ...@@ -1346,13 +1345,11 @@ static int sh_msiof_spi_probe(struct platform_device *pdev)
i = platform_get_irq(pdev, 0); i = platform_get_irq(pdev, 0);
if (i < 0) { if (i < 0) {
dev_err(&pdev->dev, "cannot get IRQ\n");
ret = i; ret = i;
goto err1; goto err1;
} }
r = platform_get_resource(pdev, IORESOURCE_MEM, 0); p->mapbase = devm_platform_ioremap_resource(pdev, 0);
p->mapbase = devm_ioremap_resource(&pdev->dev, r);
if (IS_ERR(p->mapbase)) { if (IS_ERR(p->mapbase)) {
ret = PTR_ERR(p->mapbase); ret = PTR_ERR(p->mapbase);
goto err1; goto err1;
......
...@@ -437,10 +437,8 @@ static int spi_sh_probe(struct platform_device *pdev) ...@@ -437,10 +437,8 @@ static int spi_sh_probe(struct platform_device *pdev)
} }
irq = platform_get_irq(pdev, 0); irq = platform_get_irq(pdev, 0);
if (irq < 0) { if (irq < 0)
dev_err(&pdev->dev, "platform_get_irq error: %d\n", irq);
return irq; return irq;
}
master = spi_alloc_master(&pdev->dev, sizeof(struct spi_sh_data)); master = spi_alloc_master(&pdev->dev, sizeof(struct spi_sh_data));
if (master == NULL) { if (master == NULL) {
......
...@@ -292,7 +292,6 @@ sifive_spi_transfer_one(struct spi_master *master, struct spi_device *device, ...@@ -292,7 +292,6 @@ sifive_spi_transfer_one(struct spi_master *master, struct spi_device *device,
static int sifive_spi_probe(struct platform_device *pdev) static int sifive_spi_probe(struct platform_device *pdev)
{ {
struct sifive_spi *spi; struct sifive_spi *spi;
struct resource *res;
int ret, irq, num_cs; int ret, irq, num_cs;
u32 cs_bits, max_bits_per_word; u32 cs_bits, max_bits_per_word;
struct spi_master *master; struct spi_master *master;
...@@ -307,8 +306,7 @@ static int sifive_spi_probe(struct platform_device *pdev) ...@@ -307,8 +306,7 @@ static int sifive_spi_probe(struct platform_device *pdev)
init_completion(&spi->done); init_completion(&spi->done);
platform_set_drvdata(pdev, master); platform_set_drvdata(pdev, master);
res = platform_get_resource(pdev, IORESOURCE_MEM, 0); spi->regs = devm_platform_ioremap_resource(pdev, 0);
spi->regs = devm_ioremap_resource(&pdev->dev, res);
if (IS_ERR(spi->regs)) { if (IS_ERR(spi->regs)) {
ret = PTR_ERR(spi->regs); ret = PTR_ERR(spi->regs);
goto put_master; goto put_master;
...@@ -323,7 +321,6 @@ static int sifive_spi_probe(struct platform_device *pdev) ...@@ -323,7 +321,6 @@ static int sifive_spi_probe(struct platform_device *pdev)
irq = platform_get_irq(pdev, 0); irq = platform_get_irq(pdev, 0);
if (irq < 0) { if (irq < 0) {
dev_err(&pdev->dev, "Unable to find interrupt\n");
ret = irq; ret = irq;
goto put_master; goto put_master;
} }
......
...@@ -1070,7 +1070,6 @@ static int spi_sirfsoc_probe(struct platform_device *pdev) ...@@ -1070,7 +1070,6 @@ static int spi_sirfsoc_probe(struct platform_device *pdev)
{ {
struct sirfsoc_spi *sspi; struct sirfsoc_spi *sspi;
struct spi_master *master; struct spi_master *master;
struct resource *mem_res;
const struct sirf_spi_comp_data *spi_comp_data; const struct sirf_spi_comp_data *spi_comp_data;
int irq; int irq;
int ret; int ret;
...@@ -1097,8 +1096,7 @@ static int spi_sirfsoc_probe(struct platform_device *pdev) ...@@ -1097,8 +1096,7 @@ static int spi_sirfsoc_probe(struct platform_device *pdev)
sspi->fifo_level_chk_mask = (sspi->fifo_size / 4) - 1; sspi->fifo_level_chk_mask = (sspi->fifo_size / 4) - 1;
sspi->dat_max_frm_len = spi_comp_data->dat_max_frm_len; sspi->dat_max_frm_len = spi_comp_data->dat_max_frm_len;
sspi->fifo_size = spi_comp_data->fifo_size; sspi->fifo_size = spi_comp_data->fifo_size;
mem_res = platform_get_resource(pdev, IORESOURCE_MEM, 0); sspi->base = devm_platform_ioremap_resource(pdev, 0);
sspi->base = devm_ioremap_resource(&pdev->dev, mem_res);
if (IS_ERR(sspi->base)) { if (IS_ERR(sspi->base)) {
ret = PTR_ERR(sspi->base); ret = PTR_ERR(sspi->base);
goto free_master; goto free_master;
......
...@@ -410,7 +410,6 @@ static int mtk_spi_slave_probe(struct platform_device *pdev) ...@@ -410,7 +410,6 @@ static int mtk_spi_slave_probe(struct platform_device *pdev)
irq = platform_get_irq(pdev, 0); irq = platform_get_irq(pdev, 0);
if (irq < 0) { if (irq < 0) {
dev_err(&pdev->dev, "failed to get irq (%d)\n", irq);
ret = irq; ret = irq;
goto err_put_ctlr; goto err_put_ctlr;
} }
......
...@@ -86,6 +86,7 @@ ...@@ -86,6 +86,7 @@
#define BIT_WDG_EN BIT(2) #define BIT_WDG_EN BIT(2)
/* Definition of PMIC reset status register */ /* Definition of PMIC reset status register */
#define HWRST_STATUS_SECURITY 0x02
#define HWRST_STATUS_RECOVERY 0x20 #define HWRST_STATUS_RECOVERY 0x20
#define HWRST_STATUS_NORMAL 0x40 #define HWRST_STATUS_NORMAL 0x40
#define HWRST_STATUS_ALARM 0x50 #define HWRST_STATUS_ALARM 0x50
...@@ -97,6 +98,8 @@ ...@@ -97,6 +98,8 @@
#define HWRST_STATUS_AUTODLOADER 0xa0 #define HWRST_STATUS_AUTODLOADER 0xa0
#define HWRST_STATUS_IQMODE 0xb0 #define HWRST_STATUS_IQMODE 0xb0
#define HWRST_STATUS_SPRDISK 0xc0 #define HWRST_STATUS_SPRDISK 0xc0
#define HWRST_STATUS_FACTORYTEST 0xe0
#define HWRST_STATUS_WATCHDOG 0xf0
/* Use default timeout 50 ms that converts to watchdog values */ /* Use default timeout 50 ms that converts to watchdog values */
#define WDG_LOAD_VAL ((50 * 1000) / 32768) #define WDG_LOAD_VAL ((50 * 1000) / 32768)
...@@ -162,14 +165,16 @@ static int sprd_adi_read(struct sprd_adi *sadi, u32 reg_paddr, u32 *read_val) ...@@ -162,14 +165,16 @@ static int sprd_adi_read(struct sprd_adi *sadi, u32 reg_paddr, u32 *read_val)
int read_timeout = ADI_READ_TIMEOUT; int read_timeout = ADI_READ_TIMEOUT;
unsigned long flags; unsigned long flags;
u32 val, rd_addr; u32 val, rd_addr;
int ret; int ret = 0;
ret = hwspin_lock_timeout_irqsave(sadi->hwlock, if (sadi->hwlock) {
ADI_HWSPINLOCK_TIMEOUT, ret = hwspin_lock_timeout_irqsave(sadi->hwlock,
&flags); ADI_HWSPINLOCK_TIMEOUT,
if (ret) { &flags);
dev_err(sadi->dev, "get the hw lock failed\n"); if (ret) {
return ret; dev_err(sadi->dev, "get the hw lock failed\n");
return ret;
}
} }
/* /*
...@@ -216,7 +221,8 @@ static int sprd_adi_read(struct sprd_adi *sadi, u32 reg_paddr, u32 *read_val) ...@@ -216,7 +221,8 @@ static int sprd_adi_read(struct sprd_adi *sadi, u32 reg_paddr, u32 *read_val)
*read_val = val & RD_VALUE_MASK; *read_val = val & RD_VALUE_MASK;
out: out:
hwspin_unlock_irqrestore(sadi->hwlock, &flags); if (sadi->hwlock)
hwspin_unlock_irqrestore(sadi->hwlock, &flags);
return ret; return ret;
} }
...@@ -227,12 +233,14 @@ static int sprd_adi_write(struct sprd_adi *sadi, u32 reg_paddr, u32 val) ...@@ -227,12 +233,14 @@ static int sprd_adi_write(struct sprd_adi *sadi, u32 reg_paddr, u32 val)
unsigned long flags; unsigned long flags;
int ret; int ret;
ret = hwspin_lock_timeout_irqsave(sadi->hwlock, if (sadi->hwlock) {
ADI_HWSPINLOCK_TIMEOUT, ret = hwspin_lock_timeout_irqsave(sadi->hwlock,
&flags); ADI_HWSPINLOCK_TIMEOUT,
if (ret) { &flags);
dev_err(sadi->dev, "get the hw lock failed\n"); if (ret) {
return ret; dev_err(sadi->dev, "get the hw lock failed\n");
return ret;
}
} }
ret = sprd_adi_drain_fifo(sadi); ret = sprd_adi_drain_fifo(sadi);
...@@ -258,7 +266,8 @@ static int sprd_adi_write(struct sprd_adi *sadi, u32 reg_paddr, u32 val) ...@@ -258,7 +266,8 @@ static int sprd_adi_write(struct sprd_adi *sadi, u32 reg_paddr, u32 val)
} }
out: out:
hwspin_unlock_irqrestore(sadi->hwlock, &flags); if (sadi->hwlock)
hwspin_unlock_irqrestore(sadi->hwlock, &flags);
return ret; return ret;
} }
...@@ -307,6 +316,18 @@ static int sprd_adi_transfer_one(struct spi_controller *ctlr, ...@@ -307,6 +316,18 @@ static int sprd_adi_transfer_one(struct spi_controller *ctlr,
return 0; return 0;
} }
static void sprd_adi_set_wdt_rst_mode(struct sprd_adi *sadi)
{
#ifdef CONFIG_SPRD_WATCHDOG
u32 val;
/* Set default watchdog reboot mode */
sprd_adi_read(sadi, sadi->slave_pbase + PMIC_RST_STATUS, &val);
val |= HWRST_STATUS_WATCHDOG;
sprd_adi_write(sadi, sadi->slave_pbase + PMIC_RST_STATUS, val);
#endif
}
static int sprd_adi_restart_handler(struct notifier_block *this, static int sprd_adi_restart_handler(struct notifier_block *this,
unsigned long mode, void *cmd) unsigned long mode, void *cmd)
{ {
...@@ -336,11 +357,16 @@ static int sprd_adi_restart_handler(struct notifier_block *this, ...@@ -336,11 +357,16 @@ static int sprd_adi_restart_handler(struct notifier_block *this,
reboot_mode = HWRST_STATUS_IQMODE; reboot_mode = HWRST_STATUS_IQMODE;
else if (!strncmp(cmd, "sprdisk", 7)) else if (!strncmp(cmd, "sprdisk", 7))
reboot_mode = HWRST_STATUS_SPRDISK; reboot_mode = HWRST_STATUS_SPRDISK;
else if (!strncmp(cmd, "tospanic", 8))
reboot_mode = HWRST_STATUS_SECURITY;
else if (!strncmp(cmd, "factorytest", 11))
reboot_mode = HWRST_STATUS_FACTORYTEST;
else else
reboot_mode = HWRST_STATUS_NORMAL; reboot_mode = HWRST_STATUS_NORMAL;
/* Record the reboot mode */ /* Record the reboot mode */
sprd_adi_read(sadi, sadi->slave_pbase + PMIC_RST_STATUS, &val); sprd_adi_read(sadi, sadi->slave_pbase + PMIC_RST_STATUS, &val);
val &= ~HWRST_STATUS_WATCHDOG;
val |= reboot_mode; val |= reboot_mode;
sprd_adi_write(sadi, sadi->slave_pbase + PMIC_RST_STATUS, val); sprd_adi_write(sadi, sadi->slave_pbase + PMIC_RST_STATUS, val);
...@@ -380,9 +406,6 @@ static void sprd_adi_hw_init(struct sprd_adi *sadi) ...@@ -380,9 +406,6 @@ static void sprd_adi_hw_init(struct sprd_adi *sadi)
const __be32 *list; const __be32 *list;
u32 tmp; u32 tmp;
/* Address bits select default 12 bits */
writel_relaxed(0, sadi->base + REG_ADI_CTRL0);
/* Set all channels as default priority */ /* Set all channels as default priority */
writel_relaxed(0, sadi->base + REG_ADI_CHN_PRIL); writel_relaxed(0, sadi->base + REG_ADI_CHN_PRIL);
writel_relaxed(0, sadi->base + REG_ADI_CHN_PRIH); writel_relaxed(0, sadi->base + REG_ADI_CHN_PRIH);
...@@ -459,19 +482,30 @@ static int sprd_adi_probe(struct platform_device *pdev) ...@@ -459,19 +482,30 @@ static int sprd_adi_probe(struct platform_device *pdev)
sadi->slave_pbase = res->start + ADI_SLAVE_OFFSET; sadi->slave_pbase = res->start + ADI_SLAVE_OFFSET;
sadi->ctlr = ctlr; sadi->ctlr = ctlr;
sadi->dev = &pdev->dev; sadi->dev = &pdev->dev;
ret = of_hwspin_lock_get_id_byname(np, "adi"); ret = of_hwspin_lock_get_id(np, 0);
if (ret < 0) { if (ret > 0 || (IS_ENABLED(CONFIG_HWSPINLOCK) && ret == 0)) {
dev_err(&pdev->dev, "can not get the hardware spinlock\n"); sadi->hwlock =
goto put_ctlr; devm_hwspin_lock_request_specific(&pdev->dev, ret);
} if (!sadi->hwlock) {
ret = -ENXIO;
sadi->hwlock = devm_hwspin_lock_request_specific(&pdev->dev, ret); goto put_ctlr;
if (!sadi->hwlock) { }
ret = -ENXIO; } else {
goto put_ctlr; switch (ret) {
case -ENOENT:
dev_info(&pdev->dev, "no hardware spinlock supplied\n");
break;
default:
dev_err(&pdev->dev,
"failed to find hwlock id, %d\n", ret);
/* fall-through */
case -EPROBE_DEFER:
goto put_ctlr;
}
} }
sprd_adi_hw_init(sadi); sprd_adi_hw_init(sadi);
sprd_adi_set_wdt_rst_mode(sadi);
ctlr->dev.of_node = pdev->dev.of_node; ctlr->dev.of_node = pdev->dev.of_node;
ctlr->bus_num = pdev->id; ctlr->bus_num = pdev->id;
......
...@@ -843,10 +843,8 @@ static int sprd_spi_irq_init(struct platform_device *pdev, struct sprd_spi *ss) ...@@ -843,10 +843,8 @@ static int sprd_spi_irq_init(struct platform_device *pdev, struct sprd_spi *ss)
int ret; int ret;
ss->irq = platform_get_irq(pdev, 0); ss->irq = platform_get_irq(pdev, 0);
if (ss->irq < 0) { if (ss->irq < 0)
dev_err(&pdev->dev, "failed to get irq resource\n");
return ss->irq; return ss->irq;
}
ret = devm_request_irq(&pdev->dev, ss->irq, sprd_spi_handle_irq, ret = devm_request_irq(&pdev->dev, ss->irq, sprd_spi_handle_irq,
0, pdev->name, ss); 0, pdev->name, ss);
......
...@@ -298,7 +298,6 @@ static int spi_st_probe(struct platform_device *pdev) ...@@ -298,7 +298,6 @@ static int spi_st_probe(struct platform_device *pdev)
{ {
struct device_node *np = pdev->dev.of_node; struct device_node *np = pdev->dev.of_node;
struct spi_master *master; struct spi_master *master;
struct resource *res;
struct spi_st *spi_st; struct spi_st *spi_st;
int irq, ret = 0; int irq, ret = 0;
u32 var; u32 var;
...@@ -331,8 +330,7 @@ static int spi_st_probe(struct platform_device *pdev) ...@@ -331,8 +330,7 @@ static int spi_st_probe(struct platform_device *pdev)
init_completion(&spi_st->done); init_completion(&spi_st->done);
/* Get resources */ /* Get resources */
res = platform_get_resource(pdev, IORESOURCE_MEM, 0); spi_st->base = devm_platform_ioremap_resource(pdev, 0);
spi_st->base = devm_ioremap_resource(&pdev->dev, res);
if (IS_ERR(spi_st->base)) { if (IS_ERR(spi_st->base)) {
ret = PTR_ERR(spi_st->base); ret = PTR_ERR(spi_st->base);
goto clk_disable; goto clk_disable;
......
...@@ -570,11 +570,8 @@ static int stm32_qspi_probe(struct platform_device *pdev) ...@@ -570,11 +570,8 @@ static int stm32_qspi_probe(struct platform_device *pdev)
} }
irq = platform_get_irq(pdev, 0); irq = platform_get_irq(pdev, 0);
if (irq < 0) { if (irq < 0)
if (irq != -EPROBE_DEFER)
dev_err(dev, "IRQ error missing or invalid\n");
return irq; return irq;
}
ret = devm_request_irq(dev, irq, stm32_qspi_irq, 0, ret = devm_request_irq(dev, irq, stm32_qspi_irq, 0,
dev_name(dev), qspi); dev_name(dev), qspi);
......
...@@ -428,7 +428,6 @@ static int sun4i_spi_probe(struct platform_device *pdev) ...@@ -428,7 +428,6 @@ static int sun4i_spi_probe(struct platform_device *pdev)
{ {
struct spi_master *master; struct spi_master *master;
struct sun4i_spi *sspi; struct sun4i_spi *sspi;
struct resource *res;
int ret = 0, irq; int ret = 0, irq;
master = spi_alloc_master(&pdev->dev, sizeof(struct sun4i_spi)); master = spi_alloc_master(&pdev->dev, sizeof(struct sun4i_spi));
...@@ -440,8 +439,7 @@ static int sun4i_spi_probe(struct platform_device *pdev) ...@@ -440,8 +439,7 @@ static int sun4i_spi_probe(struct platform_device *pdev)
platform_set_drvdata(pdev, master); platform_set_drvdata(pdev, master);
sspi = spi_master_get_devdata(master); sspi = spi_master_get_devdata(master);
res = platform_get_resource(pdev, IORESOURCE_MEM, 0); sspi->base_addr = devm_platform_ioremap_resource(pdev, 0);
sspi->base_addr = devm_ioremap_resource(&pdev->dev, res);
if (IS_ERR(sspi->base_addr)) { if (IS_ERR(sspi->base_addr)) {
ret = PTR_ERR(sspi->base_addr); ret = PTR_ERR(sspi->base_addr);
goto err_free_master; goto err_free_master;
...@@ -449,7 +447,6 @@ static int sun4i_spi_probe(struct platform_device *pdev) ...@@ -449,7 +447,6 @@ static int sun4i_spi_probe(struct platform_device *pdev)
irq = platform_get_irq(pdev, 0); irq = platform_get_irq(pdev, 0);
if (irq < 0) { if (irq < 0) {
dev_err(&pdev->dev, "No spi IRQ specified\n");
ret = -ENXIO; ret = -ENXIO;
goto err_free_master; goto err_free_master;
} }
......
...@@ -435,7 +435,6 @@ static int sun6i_spi_probe(struct platform_device *pdev) ...@@ -435,7 +435,6 @@ static int sun6i_spi_probe(struct platform_device *pdev)
{ {
struct spi_master *master; struct spi_master *master;
struct sun6i_spi *sspi; struct sun6i_spi *sspi;
struct resource *res;
int ret = 0, irq; int ret = 0, irq;
master = spi_alloc_master(&pdev->dev, sizeof(struct sun6i_spi)); master = spi_alloc_master(&pdev->dev, sizeof(struct sun6i_spi));
...@@ -447,8 +446,7 @@ static int sun6i_spi_probe(struct platform_device *pdev) ...@@ -447,8 +446,7 @@ static int sun6i_spi_probe(struct platform_device *pdev)
platform_set_drvdata(pdev, master); platform_set_drvdata(pdev, master);
sspi = spi_master_get_devdata(master); sspi = spi_master_get_devdata(master);
res = platform_get_resource(pdev, IORESOURCE_MEM, 0); sspi->base_addr = devm_platform_ioremap_resource(pdev, 0);
sspi->base_addr = devm_ioremap_resource(&pdev->dev, res);
if (IS_ERR(sspi->base_addr)) { if (IS_ERR(sspi->base_addr)) {
ret = PTR_ERR(sspi->base_addr); ret = PTR_ERR(sspi->base_addr);
goto err_free_master; goto err_free_master;
...@@ -456,7 +454,6 @@ static int sun6i_spi_probe(struct platform_device *pdev) ...@@ -456,7 +454,6 @@ static int sun6i_spi_probe(struct platform_device *pdev)
irq = platform_get_irq(pdev, 0); irq = platform_get_irq(pdev, 0);
if (irq < 0) { if (irq < 0) {
dev_err(&pdev->dev, "No spi IRQ specified\n");
ret = -ENXIO; ret = -ENXIO;
goto err_free_master; goto err_free_master;
} }
......
...@@ -670,7 +670,6 @@ static int synquacer_spi_probe(struct platform_device *pdev) ...@@ -670,7 +670,6 @@ static int synquacer_spi_probe(struct platform_device *pdev)
rx_irq = platform_get_irq(pdev, 0); rx_irq = platform_get_irq(pdev, 0);
if (rx_irq <= 0) { if (rx_irq <= 0) {
dev_err(&pdev->dev, "get rx_irq failed (%d)\n", rx_irq);
ret = rx_irq; ret = rx_irq;
goto put_spi; goto put_spi;
} }
...@@ -685,7 +684,6 @@ static int synquacer_spi_probe(struct platform_device *pdev) ...@@ -685,7 +684,6 @@ static int synquacer_spi_probe(struct platform_device *pdev)
tx_irq = platform_get_irq(pdev, 1); tx_irq = platform_get_irq(pdev, 1);
if (tx_irq <= 0) { if (tx_irq <= 0) {
dev_err(&pdev->dev, "get tx_irq failed (%d)\n", tx_irq);
ret = tx_irq; ret = tx_irq;
goto put_spi; goto put_spi;
} }
......
...@@ -419,7 +419,6 @@ static int tegra_sflash_probe(struct platform_device *pdev) ...@@ -419,7 +419,6 @@ static int tegra_sflash_probe(struct platform_device *pdev)
{ {
struct spi_master *master; struct spi_master *master;
struct tegra_sflash_data *tsd; struct tegra_sflash_data *tsd;
struct resource *r;
int ret; int ret;
const struct of_device_id *match; const struct of_device_id *match;
...@@ -451,8 +450,7 @@ static int tegra_sflash_probe(struct platform_device *pdev) ...@@ -451,8 +450,7 @@ static int tegra_sflash_probe(struct platform_device *pdev)
&master->max_speed_hz)) &master->max_speed_hz))
master->max_speed_hz = 25000000; /* 25MHz */ master->max_speed_hz = 25000000; /* 25MHz */
r = platform_get_resource(pdev, IORESOURCE_MEM, 0); tsd->base = devm_platform_ioremap_resource(pdev, 0);
tsd->base = devm_ioremap_resource(&pdev->dev, r);
if (IS_ERR(tsd->base)) { if (IS_ERR(tsd->base)) {
ret = PTR_ERR(tsd->base); ret = PTR_ERR(tsd->base);
goto exit_free_master; goto exit_free_master;
......
...@@ -717,7 +717,6 @@ static int ti_qspi_probe(struct platform_device *pdev) ...@@ -717,7 +717,6 @@ static int ti_qspi_probe(struct platform_device *pdev)
irq = platform_get_irq(pdev, 0); irq = platform_get_irq(pdev, 0);
if (irq < 0) { if (irq < 0) {
dev_err(&pdev->dev, "no irq resource?\n");
ret = irq; ret = irq;
goto free_master; goto free_master;
} }
......
...@@ -7,6 +7,7 @@ ...@@ -7,6 +7,7 @@
#include <linux/bitfield.h> #include <linux/bitfield.h>
#include <linux/bitops.h> #include <linux/bitops.h>
#include <linux/clk.h> #include <linux/clk.h>
#include <linux/delay.h>
#include <linux/interrupt.h> #include <linux/interrupt.h>
#include <linux/io.h> #include <linux/io.h>
#include <linux/module.h> #include <linux/module.h>
...@@ -16,6 +17,7 @@ ...@@ -16,6 +17,7 @@
#include <asm/unaligned.h> #include <asm/unaligned.h>
#define SSI_TIMEOUT_MS 2000 #define SSI_TIMEOUT_MS 2000
#define SSI_POLL_TIMEOUT_US 200
#define SSI_MAX_CLK_DIVIDER 254 #define SSI_MAX_CLK_DIVIDER 254
#define SSI_MIN_CLK_DIVIDER 4 #define SSI_MIN_CLK_DIVIDER 4
...@@ -227,8 +229,7 @@ static void uniphier_spi_setup_transfer(struct spi_device *spi, ...@@ -227,8 +229,7 @@ static void uniphier_spi_setup_transfer(struct spi_device *spi,
priv->speed_hz = t->speed_hz; priv->speed_hz = t->speed_hz;
} }
if (!priv->is_save_param) priv->is_save_param = true;
priv->is_save_param = true;
/* reset FIFOs */ /* reset FIFOs */
val = SSI_FC_TXFFL | SSI_FC_RXFFL; val = SSI_FC_TXFFL | SSI_FC_RXFFL;
...@@ -291,21 +292,23 @@ static void uniphier_spi_recv(struct uniphier_spi_priv *priv) ...@@ -291,21 +292,23 @@ static void uniphier_spi_recv(struct uniphier_spi_priv *priv)
static void uniphier_spi_fill_tx_fifo(struct uniphier_spi_priv *priv) static void uniphier_spi_fill_tx_fifo(struct uniphier_spi_priv *priv)
{ {
unsigned int tx_count; unsigned int fifo_threshold, fill_bytes;
u32 val; u32 val;
tx_count = DIV_ROUND_UP(priv->tx_bytes, fifo_threshold = DIV_ROUND_UP(priv->rx_bytes,
bytes_per_word(priv->bits_per_word)); bytes_per_word(priv->bits_per_word));
tx_count = min(tx_count, SSI_FIFO_DEPTH); fifo_threshold = min(fifo_threshold, SSI_FIFO_DEPTH);
fill_bytes = fifo_threshold - (priv->rx_bytes - priv->tx_bytes);
/* set fifo threshold */ /* set fifo threshold */
val = readl(priv->base + SSI_FC); val = readl(priv->base + SSI_FC);
val &= ~(SSI_FC_TXFTH_MASK | SSI_FC_RXFTH_MASK); val &= ~(SSI_FC_TXFTH_MASK | SSI_FC_RXFTH_MASK);
val |= FIELD_PREP(SSI_FC_TXFTH_MASK, tx_count); val |= FIELD_PREP(SSI_FC_TXFTH_MASK, fifo_threshold);
val |= FIELD_PREP(SSI_FC_RXFTH_MASK, tx_count); val |= FIELD_PREP(SSI_FC_RXFTH_MASK, fifo_threshold);
writel(val, priv->base + SSI_FC); writel(val, priv->base + SSI_FC);
while (tx_count--) while (fill_bytes--)
uniphier_spi_send(priv); uniphier_spi_send(priv);
} }
...@@ -324,20 +327,14 @@ static void uniphier_spi_set_cs(struct spi_device *spi, bool enable) ...@@ -324,20 +327,14 @@ static void uniphier_spi_set_cs(struct spi_device *spi, bool enable)
writel(val, priv->base + SSI_FPS); writel(val, priv->base + SSI_FPS);
} }
static int uniphier_spi_transfer_one(struct spi_master *master, static int uniphier_spi_transfer_one_irq(struct spi_master *master,
struct spi_device *spi, struct spi_device *spi,
struct spi_transfer *t) struct spi_transfer *t)
{ {
struct uniphier_spi_priv *priv = spi_master_get_devdata(master); struct uniphier_spi_priv *priv = spi_master_get_devdata(master);
struct device *dev = master->dev.parent; struct device *dev = master->dev.parent;
unsigned long time_left; unsigned long time_left;
/* Terminate and return success for 0 byte length transfer */
if (!t->len)
return 0;
uniphier_spi_setup_transfer(spi, t);
reinit_completion(&priv->xfer_done); reinit_completion(&priv->xfer_done);
uniphier_spi_fill_tx_fifo(priv); uniphier_spi_fill_tx_fifo(priv);
...@@ -357,6 +354,59 @@ static int uniphier_spi_transfer_one(struct spi_master *master, ...@@ -357,6 +354,59 @@ static int uniphier_spi_transfer_one(struct spi_master *master,
return priv->error; return priv->error;
} }
static int uniphier_spi_transfer_one_poll(struct spi_master *master,
struct spi_device *spi,
struct spi_transfer *t)
{
struct uniphier_spi_priv *priv = spi_master_get_devdata(master);
int loop = SSI_POLL_TIMEOUT_US * 10;
while (priv->tx_bytes) {
uniphier_spi_fill_tx_fifo(priv);
while ((priv->rx_bytes - priv->tx_bytes) > 0) {
while (!(readl(priv->base + SSI_SR) & SSI_SR_RNE)
&& loop--)
ndelay(100);
if (loop == -1)
goto irq_transfer;
uniphier_spi_recv(priv);
}
}
return 0;
irq_transfer:
return uniphier_spi_transfer_one_irq(master, spi, t);
}
static int uniphier_spi_transfer_one(struct spi_master *master,
struct spi_device *spi,
struct spi_transfer *t)
{
struct uniphier_spi_priv *priv = spi_master_get_devdata(master);
unsigned long threshold;
/* Terminate and return success for 0 byte length transfer */
if (!t->len)
return 0;
uniphier_spi_setup_transfer(spi, t);
/*
* If the transfer operation will take longer than
* SSI_POLL_TIMEOUT_US, it should use irq.
*/
threshold = DIV_ROUND_UP(SSI_POLL_TIMEOUT_US * priv->speed_hz,
USEC_PER_SEC * BITS_PER_BYTE);
if (t->len > threshold)
return uniphier_spi_transfer_one_irq(master, spi, t);
else
return uniphier_spi_transfer_one_poll(master, spi, t);
}
static int uniphier_spi_prepare_transfer_hardware(struct spi_master *master) static int uniphier_spi_prepare_transfer_hardware(struct spi_master *master)
{ {
struct uniphier_spi_priv *priv = spi_master_get_devdata(master); struct uniphier_spi_priv *priv = spi_master_get_devdata(master);
...@@ -420,7 +470,6 @@ static int uniphier_spi_probe(struct platform_device *pdev) ...@@ -420,7 +470,6 @@ static int uniphier_spi_probe(struct platform_device *pdev)
{ {
struct uniphier_spi_priv *priv; struct uniphier_spi_priv *priv;
struct spi_master *master; struct spi_master *master;
struct resource *res;
unsigned long clk_rate; unsigned long clk_rate;
int irq; int irq;
int ret; int ret;
...@@ -435,8 +484,7 @@ static int uniphier_spi_probe(struct platform_device *pdev) ...@@ -435,8 +484,7 @@ static int uniphier_spi_probe(struct platform_device *pdev)
priv->master = master; priv->master = master;
priv->is_save_param = false; priv->is_save_param = false;
res = platform_get_resource(pdev, IORESOURCE_MEM, 0); priv->base = devm_platform_ioremap_resource(pdev, 0);
priv->base = devm_ioremap_resource(&pdev->dev, res);
if (IS_ERR(priv->base)) { if (IS_ERR(priv->base)) {
ret = PTR_ERR(priv->base); ret = PTR_ERR(priv->base);
goto out_master_put; goto out_master_put;
...@@ -455,7 +503,6 @@ static int uniphier_spi_probe(struct platform_device *pdev) ...@@ -455,7 +503,6 @@ static int uniphier_spi_probe(struct platform_device *pdev)
irq = platform_get_irq(pdev, 0); irq = platform_get_irq(pdev, 0);
if (irq < 0) { if (irq < 0) {
dev_err(&pdev->dev, "failed to get IRQ\n");
ret = irq; ret = irq;
goto out_disable_clk; goto out_disable_clk;
} }
......
...@@ -370,7 +370,6 @@ static int xlp_spi_probe(struct platform_device *pdev) ...@@ -370,7 +370,6 @@ static int xlp_spi_probe(struct platform_device *pdev)
{ {
struct spi_master *master; struct spi_master *master;
struct xlp_spi_priv *xspi; struct xlp_spi_priv *xspi;
struct resource *res;
struct clk *clk; struct clk *clk;
int irq, err; int irq, err;
...@@ -378,16 +377,13 @@ static int xlp_spi_probe(struct platform_device *pdev) ...@@ -378,16 +377,13 @@ static int xlp_spi_probe(struct platform_device *pdev)
if (!xspi) if (!xspi)
return -ENOMEM; return -ENOMEM;
res = platform_get_resource(pdev, IORESOURCE_MEM, 0); xspi->base = devm_platform_ioremap_resource(pdev, 0);
xspi->base = devm_ioremap_resource(&pdev->dev, res);
if (IS_ERR(xspi->base)) if (IS_ERR(xspi->base))
return PTR_ERR(xspi->base); return PTR_ERR(xspi->base);
irq = platform_get_irq(pdev, 0); irq = platform_get_irq(pdev, 0);
if (irq < 0) { if (irq < 0)
dev_err(&pdev->dev, "no IRQ resource found: %d\n", irq);
return irq; return irq;
}
err = devm_request_irq(&pdev->dev, irq, xlp_spi_interrupt, 0, err = devm_request_irq(&pdev->dev, irq, xlp_spi_interrupt, 0,
pdev->name, xspi); pdev->name, xspi);
if (err) { if (err) {
......
...@@ -620,7 +620,6 @@ static int zynq_qspi_probe(struct platform_device *pdev) ...@@ -620,7 +620,6 @@ static int zynq_qspi_probe(struct platform_device *pdev)
struct device *dev = &pdev->dev; struct device *dev = &pdev->dev;
struct device_node *np = dev->of_node; struct device_node *np = dev->of_node;
struct zynq_qspi *xqspi; struct zynq_qspi *xqspi;
struct resource *res;
u32 num_cs; u32 num_cs;
ctlr = spi_alloc_master(&pdev->dev, sizeof(*xqspi)); ctlr = spi_alloc_master(&pdev->dev, sizeof(*xqspi));
...@@ -630,8 +629,7 @@ static int zynq_qspi_probe(struct platform_device *pdev) ...@@ -630,8 +629,7 @@ static int zynq_qspi_probe(struct platform_device *pdev)
xqspi = spi_controller_get_devdata(ctlr); xqspi = spi_controller_get_devdata(ctlr);
xqspi->dev = dev; xqspi->dev = dev;
platform_set_drvdata(pdev, xqspi); platform_set_drvdata(pdev, xqspi);
res = platform_get_resource(pdev, IORESOURCE_MEM, 0); xqspi->regs = devm_platform_ioremap_resource(pdev, 0);
xqspi->regs = devm_ioremap_resource(&pdev->dev, res);
if (IS_ERR(xqspi->regs)) { if (IS_ERR(xqspi->regs)) {
ret = PTR_ERR(xqspi->regs); ret = PTR_ERR(xqspi->regs);
goto remove_master; goto remove_master;
...@@ -671,7 +669,6 @@ static int zynq_qspi_probe(struct platform_device *pdev) ...@@ -671,7 +669,6 @@ static int zynq_qspi_probe(struct platform_device *pdev)
xqspi->irq = platform_get_irq(pdev, 0); xqspi->irq = platform_get_irq(pdev, 0);
if (xqspi->irq <= 0) { if (xqspi->irq <= 0) {
ret = -ENXIO; ret = -ENXIO;
dev_err(&pdev->dev, "irq resource not found\n");
goto remove_master; goto remove_master;
} }
ret = devm_request_irq(&pdev->dev, xqspi->irq, zynq_qspi_irq, ret = devm_request_irq(&pdev->dev, xqspi->irq, zynq_qspi_irq,
......
...@@ -1016,7 +1016,6 @@ static int zynqmp_qspi_probe(struct platform_device *pdev) ...@@ -1016,7 +1016,6 @@ static int zynqmp_qspi_probe(struct platform_device *pdev)
int ret = 0; int ret = 0;
struct spi_master *master; struct spi_master *master;
struct zynqmp_qspi *xqspi; struct zynqmp_qspi *xqspi;
struct resource *res;
struct device *dev = &pdev->dev; struct device *dev = &pdev->dev;
eemi_ops = zynqmp_pm_get_eemi_ops(); eemi_ops = zynqmp_pm_get_eemi_ops();
...@@ -1031,8 +1030,7 @@ static int zynqmp_qspi_probe(struct platform_device *pdev) ...@@ -1031,8 +1030,7 @@ static int zynqmp_qspi_probe(struct platform_device *pdev)
master->dev.of_node = pdev->dev.of_node; master->dev.of_node = pdev->dev.of_node;
platform_set_drvdata(pdev, master); platform_set_drvdata(pdev, master);
res = platform_get_resource(pdev, IORESOURCE_MEM, 0); xqspi->regs = devm_platform_ioremap_resource(pdev, 0);
xqspi->regs = devm_ioremap_resource(&pdev->dev, res);
if (IS_ERR(xqspi->regs)) { if (IS_ERR(xqspi->regs)) {
ret = PTR_ERR(xqspi->regs); ret = PTR_ERR(xqspi->regs);
goto remove_master; goto remove_master;
...@@ -1077,7 +1075,6 @@ static int zynqmp_qspi_probe(struct platform_device *pdev) ...@@ -1077,7 +1075,6 @@ static int zynqmp_qspi_probe(struct platform_device *pdev)
xqspi->irq = platform_get_irq(pdev, 0); xqspi->irq = platform_get_irq(pdev, 0);
if (xqspi->irq <= 0) { if (xqspi->irq <= 0) {
ret = -ENXIO; ret = -ENXIO;
dev_err(dev, "irq resource not found\n");
goto clk_dis_all; goto clk_dis_all;
} }
ret = devm_request_irq(&pdev->dev, xqspi->irq, zynqmp_qspi_irq, ret = devm_request_irq(&pdev->dev, xqspi->irq, zynqmp_qspi_irq,
......
...@@ -1265,8 +1265,9 @@ EXPORT_SYMBOL_GPL(spi_finalize_current_transfer); ...@@ -1265,8 +1265,9 @@ EXPORT_SYMBOL_GPL(spi_finalize_current_transfer);
*/ */
static void __spi_pump_messages(struct spi_controller *ctlr, bool in_kthread) static void __spi_pump_messages(struct spi_controller *ctlr, bool in_kthread)
{ {
unsigned long flags; struct spi_message *msg;
bool was_busy = false; bool was_busy = false;
unsigned long flags;
int ret; int ret;
/* Lock queue */ /* Lock queue */
...@@ -1325,10 +1326,10 @@ static void __spi_pump_messages(struct spi_controller *ctlr, bool in_kthread) ...@@ -1325,10 +1326,10 @@ static void __spi_pump_messages(struct spi_controller *ctlr, bool in_kthread)
} }
/* Extract head of queue */ /* Extract head of queue */
ctlr->cur_msg = msg = list_first_entry(&ctlr->queue, struct spi_message, queue);
list_first_entry(&ctlr->queue, struct spi_message, queue); ctlr->cur_msg = msg;
list_del_init(&ctlr->cur_msg->queue); list_del_init(&msg->queue);
if (ctlr->busy) if (ctlr->busy)
was_busy = true; was_busy = true;
else else
...@@ -1361,7 +1362,7 @@ static void __spi_pump_messages(struct spi_controller *ctlr, bool in_kthread) ...@@ -1361,7 +1362,7 @@ static void __spi_pump_messages(struct spi_controller *ctlr, bool in_kthread)
if (ctlr->auto_runtime_pm) if (ctlr->auto_runtime_pm)
pm_runtime_put(ctlr->dev.parent); pm_runtime_put(ctlr->dev.parent);
ctlr->cur_msg->status = ret; msg->status = ret;
spi_finalize_current_message(ctlr); spi_finalize_current_message(ctlr);
mutex_unlock(&ctlr->io_mutex); mutex_unlock(&ctlr->io_mutex);
...@@ -1369,28 +1370,28 @@ static void __spi_pump_messages(struct spi_controller *ctlr, bool in_kthread) ...@@ -1369,28 +1370,28 @@ static void __spi_pump_messages(struct spi_controller *ctlr, bool in_kthread)
} }
} }
trace_spi_message_start(ctlr->cur_msg); trace_spi_message_start(msg);
if (ctlr->prepare_message) { if (ctlr->prepare_message) {
ret = ctlr->prepare_message(ctlr, ctlr->cur_msg); ret = ctlr->prepare_message(ctlr, msg);
if (ret) { if (ret) {
dev_err(&ctlr->dev, "failed to prepare message: %d\n", dev_err(&ctlr->dev, "failed to prepare message: %d\n",
ret); ret);
ctlr->cur_msg->status = ret; msg->status = ret;
spi_finalize_current_message(ctlr); spi_finalize_current_message(ctlr);
goto out; goto out;
} }
ctlr->cur_msg_prepared = true; ctlr->cur_msg_prepared = true;
} }
ret = spi_map_msg(ctlr, ctlr->cur_msg); ret = spi_map_msg(ctlr, msg);
if (ret) { if (ret) {
ctlr->cur_msg->status = ret; msg->status = ret;
spi_finalize_current_message(ctlr); spi_finalize_current_message(ctlr);
goto out; goto out;
} }
ret = ctlr->transfer_one_message(ctlr, ctlr->cur_msg); ret = ctlr->transfer_one_message(ctlr, msg);
if (ret) { if (ret) {
dev_err(&ctlr->dev, dev_err(&ctlr->dev,
"failed to transfer one message from queue\n"); "failed to transfer one message from queue\n");
...@@ -1434,7 +1435,7 @@ static void spi_pump_messages(struct kthread_work *work) ...@@ -1434,7 +1435,7 @@ static void spi_pump_messages(struct kthread_work *work)
*/ */
static void spi_set_thread_rt(struct spi_controller *ctlr) static void spi_set_thread_rt(struct spi_controller *ctlr)
{ {
struct sched_param param = { .sched_priority = MAX_RT_PRIO - 1 }; struct sched_param param = { .sched_priority = MAX_RT_PRIO / 2 };
dev_info(&ctlr->dev, dev_info(&ctlr->dev,
"will run message pump with realtime priority\n"); "will run message pump with realtime priority\n");
...@@ -2105,8 +2106,8 @@ static int match_true(struct device *dev, void *data) ...@@ -2105,8 +2106,8 @@ static int match_true(struct device *dev, void *data)
return 1; return 1;
} }
static ssize_t spi_slave_show(struct device *dev, static ssize_t slave_show(struct device *dev, struct device_attribute *attr,
struct device_attribute *attr, char *buf) char *buf)
{ {
struct spi_controller *ctlr = container_of(dev, struct spi_controller, struct spi_controller *ctlr = container_of(dev, struct spi_controller,
dev); dev);
...@@ -2117,9 +2118,8 @@ static ssize_t spi_slave_show(struct device *dev, ...@@ -2117,9 +2118,8 @@ static ssize_t spi_slave_show(struct device *dev,
child ? to_spi_device(child)->modalias : NULL); child ? to_spi_device(child)->modalias : NULL);
} }
static ssize_t spi_slave_store(struct device *dev, static ssize_t slave_store(struct device *dev, struct device_attribute *attr,
struct device_attribute *attr, const char *buf, const char *buf, size_t count)
size_t count)
{ {
struct spi_controller *ctlr = container_of(dev, struct spi_controller, struct spi_controller *ctlr = container_of(dev, struct spi_controller,
dev); dev);
...@@ -2157,7 +2157,7 @@ static ssize_t spi_slave_store(struct device *dev, ...@@ -2157,7 +2157,7 @@ static ssize_t spi_slave_store(struct device *dev,
return count; return count;
} }
static DEVICE_ATTR(slave, 0644, spi_slave_show, spi_slave_store); static DEVICE_ATTR_RW(slave);
static struct attribute *spi_slave_attrs[] = { static struct attribute *spi_slave_attrs[] = {
&dev_attr_slave.attr, &dev_attr_slave.attr,
...@@ -2188,8 +2188,10 @@ extern struct class spi_slave_class; /* dummy */ ...@@ -2188,8 +2188,10 @@ extern struct class spi_slave_class; /* dummy */
* __spi_alloc_controller - allocate an SPI master or slave controller * __spi_alloc_controller - allocate an SPI master or slave controller
* @dev: the controller, possibly using the platform_bus * @dev: the controller, possibly using the platform_bus
* @size: how much zeroed driver-private data to allocate; the pointer to this * @size: how much zeroed driver-private data to allocate; the pointer to this
* memory is in the driver_data field of the returned device, * memory is in the driver_data field of the returned device, accessible
* accessible with spi_controller_get_devdata(). * with spi_controller_get_devdata(); the memory is cacheline aligned;
* drivers granting DMA access to portions of their private data need to
* round up @size using ALIGN(size, dma_get_cache_alignment()).
* @slave: flag indicating whether to allocate an SPI master (false) or SPI * @slave: flag indicating whether to allocate an SPI master (false) or SPI
* slave (true) controller * slave (true) controller
* Context: can sleep * Context: can sleep
...@@ -2211,11 +2213,12 @@ struct spi_controller *__spi_alloc_controller(struct device *dev, ...@@ -2211,11 +2213,12 @@ struct spi_controller *__spi_alloc_controller(struct device *dev,
unsigned int size, bool slave) unsigned int size, bool slave)
{ {
struct spi_controller *ctlr; struct spi_controller *ctlr;
size_t ctlr_size = ALIGN(sizeof(*ctlr), dma_get_cache_alignment());
if (!dev) if (!dev)
return NULL; return NULL;
ctlr = kzalloc(size + sizeof(*ctlr), GFP_KERNEL); ctlr = kzalloc(size + ctlr_size, GFP_KERNEL);
if (!ctlr) if (!ctlr)
return NULL; return NULL;
...@@ -2229,14 +2232,14 @@ struct spi_controller *__spi_alloc_controller(struct device *dev, ...@@ -2229,14 +2232,14 @@ struct spi_controller *__spi_alloc_controller(struct device *dev,
ctlr->dev.class = &spi_master_class; ctlr->dev.class = &spi_master_class;
ctlr->dev.parent = dev; ctlr->dev.parent = dev;
pm_suspend_ignore_children(&ctlr->dev, true); pm_suspend_ignore_children(&ctlr->dev, true);
spi_controller_set_devdata(ctlr, &ctlr[1]); spi_controller_set_devdata(ctlr, (void *)ctlr + ctlr_size);
return ctlr; return ctlr;
} }
EXPORT_SYMBOL_GPL(__spi_alloc_controller); EXPORT_SYMBOL_GPL(__spi_alloc_controller);
#ifdef CONFIG_OF #ifdef CONFIG_OF
static int of_spi_register_master(struct spi_controller *ctlr) static int of_spi_get_gpio_numbers(struct spi_controller *ctlr)
{ {
int nb, i, *cs; int nb, i, *cs;
struct device_node *np = ctlr->dev.of_node; struct device_node *np = ctlr->dev.of_node;
...@@ -2269,7 +2272,7 @@ static int of_spi_register_master(struct spi_controller *ctlr) ...@@ -2269,7 +2272,7 @@ static int of_spi_register_master(struct spi_controller *ctlr)
return 0; return 0;
} }
#else #else
static int of_spi_register_master(struct spi_controller *ctlr) static int of_spi_get_gpio_numbers(struct spi_controller *ctlr)
{ {
return 0; return 0;
} }
...@@ -2456,7 +2459,7 @@ int spi_register_controller(struct spi_controller *ctlr) ...@@ -2456,7 +2459,7 @@ int spi_register_controller(struct spi_controller *ctlr)
ctlr->mode_bits |= SPI_CS_HIGH; ctlr->mode_bits |= SPI_CS_HIGH;
} else { } else {
/* Legacy code path for GPIOs from DT */ /* Legacy code path for GPIOs from DT */
status = of_spi_register_master(ctlr); status = of_spi_get_gpio_numbers(ctlr);
if (status) if (status)
return status; return status;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment