Commit a34fc82e authored by Grant Likely's avatar Grant Likely

Merge branch 'spi-next' from git://git.kernel.org/pub/scm/linux/kernel/git/broonie/misc.git

Pull in the changes Mark has queued up for SPI
parents 161b96c3 227c4ce6
NVIDIA Tegra20 SFLASH controller.
Required properties:
- compatible : should be "nvidia,tegra20-sflash".
- reg: Should contain SFLASH registers location and length.
- interrupts: Should contain SFLASH interrupts.
- nvidia,dma-request-selector : The Tegra DMA controller's phandle and
request selector for this SFLASH controller.
Recommended properties:
- spi-max-frequency: Definition as per
Documentation/devicetree/bindings/spi/spi-bus.txt
Example:
spi@7000d600 {
compatible = "nvidia,tegra20-sflash";
reg = <0x7000c380 0x80>;
interrupts = <0 39 0x04>;
nvidia,dma-request-selector = <&apbdma 16>;
spi-max-frequency = <25000000>;
#address-cells = <1>;
#size-cells = <0>;
status = "disabled";
};
NVIDIA Tegra20/Tegra30 SLINK controller.
Required properties:
- compatible : should be "nvidia,tegra20-slink", "nvidia,tegra30-slink".
- reg: Should contain SLINK registers location and length.
- interrupts: Should contain SLINK interrupts.
- nvidia,dma-request-selector : The Tegra DMA controller's phandle and
request selector for this SLINK controller.
Recommended properties:
- spi-max-frequency: Definition as per
Documentation/devicetree/bindings/spi/spi-bus.txt
Example:
slink@7000d600 {
compatible = "nvidia,tegra20-slink";
reg = <0x7000d600 0x200>;
interrupts = <0 82 0x04>;
nvidia,dma-request-selector = <&apbdma 16>;
spi-max-frequency = <25000000>;
#address-cells = <1>;
#size-cells = <0>;
status = "disabled";
};
...@@ -6,7 +6,9 @@ Required properties: ...@@ -6,7 +6,9 @@ Required properties:
- "ti,omap4-spi" for OMAP4+. - "ti,omap4-spi" for OMAP4+.
- ti,spi-num-cs : Number of chipselect supported by the instance. - ti,spi-num-cs : Number of chipselect supported by the instance.
- ti,hwmods: Name of the hwmod associated to the McSPI - ti,hwmods: Name of the hwmod associated to the McSPI
- ti,pindir-d0-out-d1-in: Select the D0 pin as output and D1 as
input. The default is D0 as input and
D1 as output.
Example: Example:
......
...@@ -392,6 +392,20 @@ config SPI_MXS ...@@ -392,6 +392,20 @@ config SPI_MXS
help help
SPI driver for Freescale MXS devices. SPI driver for Freescale MXS devices.
config SPI_TEGRA20_SFLASH
tristate "Nvidia Tegra20 Serial flash Controller"
depends on ARCH_TEGRA
help
SPI driver for Nvidia Tegra20 Serial flash Controller interface.
The main usecase of this controller is to use spi flash as boot
device.
config SPI_TEGRA20_SLINK
tristate "Nvidia Tegra20/Tegra30 SLINK Controller"
depends on ARCH_TEGRA && TEGRA20_APB_DMA
help
SPI driver for Nvidia Tegra20/Tegra30 SLINK Controller interface.
config SPI_TI_SSP config SPI_TI_SSP
tristate "TI Sequencer Serial Port - SPI Support" tristate "TI Sequencer Serial Port - SPI Support"
depends on MFD_TI_SSP depends on MFD_TI_SSP
......
...@@ -61,10 +61,11 @@ obj-$(CONFIG_SPI_SH_MSIOF) += spi-sh-msiof.o ...@@ -61,10 +61,11 @@ obj-$(CONFIG_SPI_SH_MSIOF) += spi-sh-msiof.o
obj-$(CONFIG_SPI_SH_SCI) += spi-sh-sci.o obj-$(CONFIG_SPI_SH_SCI) += spi-sh-sci.o
obj-$(CONFIG_SPI_SIRF) += spi-sirf.o obj-$(CONFIG_SPI_SIRF) += spi-sirf.o
obj-$(CONFIG_SPI_STMP3XXX) += spi-stmp.o obj-$(CONFIG_SPI_STMP3XXX) += spi-stmp.o
obj-$(CONFIG_SPI_TEGRA20_SFLASH) += spi-tegra20-sflash.o
obj-$(CONFIG_SPI_TEGRA20_SLINK) += spi-tegra20-slink.o
obj-$(CONFIG_SPI_TI_SSP) += spi-ti-ssp.o obj-$(CONFIG_SPI_TI_SSP) += spi-ti-ssp.o
obj-$(CONFIG_SPI_TLE62X0) += spi-tle62x0.o obj-$(CONFIG_SPI_TLE62X0) += spi-tle62x0.o
obj-$(CONFIG_SPI_TOPCLIFF_PCH) += spi-topcliff-pch.o obj-$(CONFIG_SPI_TOPCLIFF_PCH) += spi-topcliff-pch.o
obj-$(CONFIG_SPI_TXX9) += spi-txx9.o obj-$(CONFIG_SPI_TXX9) += spi-txx9.o
obj-$(CONFIG_SPI_XCOMM) += spi-xcomm.o obj-$(CONFIG_SPI_XCOMM) += spi-xcomm.o
obj-$(CONFIG_SPI_XILINX) += spi-xilinx.o obj-$(CONFIG_SPI_XILINX) += spi-xilinx.o
...@@ -36,7 +36,6 @@ ...@@ -36,7 +36,6 @@
#include <bcm63xx_dev_spi.h> #include <bcm63xx_dev_spi.h>
#define PFX KBUILD_MODNAME #define PFX KBUILD_MODNAME
#define DRV_VER "0.1.2"
struct bcm63xx_spi { struct bcm63xx_spi {
struct completion done; struct completion done;
...@@ -170,13 +169,6 @@ static int bcm63xx_spi_setup(struct spi_device *spi) ...@@ -170,13 +169,6 @@ static int bcm63xx_spi_setup(struct spi_device *spi)
return -EINVAL; return -EINVAL;
} }
ret = bcm63xx_spi_check_transfer(spi, NULL);
if (ret < 0) {
dev_err(&spi->dev, "setup: unsupported mode bits %x\n",
spi->mode & ~MODEBITS);
return ret;
}
dev_dbg(&spi->dev, "%s, mode %d, %u bits/w, %u nsec/bit\n", dev_dbg(&spi->dev, "%s, mode %d, %u bits/w, %u nsec/bit\n",
__func__, spi->mode & MODEBITS, spi->bits_per_word, 0); __func__, spi->mode & MODEBITS, spi->bits_per_word, 0);
...@@ -441,8 +433,8 @@ static int __devinit bcm63xx_spi_probe(struct platform_device *pdev) ...@@ -441,8 +433,8 @@ static int __devinit bcm63xx_spi_probe(struct platform_device *pdev)
goto out_clk_disable; goto out_clk_disable;
} }
dev_info(dev, "at 0x%08x (irq %d, FIFOs size %d) v%s\n", dev_info(dev, "at 0x%08x (irq %d, FIFOs size %d)\n",
r->start, irq, bs->fifo_size, DRV_VER); r->start, irq, bs->fifo_size);
return 0; return 0;
...@@ -485,6 +477,8 @@ static int bcm63xx_spi_suspend(struct device *dev) ...@@ -485,6 +477,8 @@ static int bcm63xx_spi_suspend(struct device *dev)
platform_get_drvdata(to_platform_device(dev)); platform_get_drvdata(to_platform_device(dev));
struct bcm63xx_spi *bs = spi_master_get_devdata(master); struct bcm63xx_spi *bs = spi_master_get_devdata(master);
spi_master_suspend(master);
clk_disable(bs->clk); clk_disable(bs->clk);
return 0; return 0;
...@@ -498,6 +492,8 @@ static int bcm63xx_spi_resume(struct device *dev) ...@@ -498,6 +492,8 @@ static int bcm63xx_spi_resume(struct device *dev)
clk_enable(bs->clk); clk_enable(bs->clk);
spi_master_resume(master);
return 0; return 0;
} }
......
...@@ -129,6 +129,7 @@ struct omap2_mcspi { ...@@ -129,6 +129,7 @@ struct omap2_mcspi {
struct omap2_mcspi_dma *dma_channels; struct omap2_mcspi_dma *dma_channels;
struct device *dev; struct device *dev;
struct omap2_mcspi_regs ctx; struct omap2_mcspi_regs ctx;
unsigned int pin_dir:1;
}; };
struct omap2_mcspi_cs { struct omap2_mcspi_cs {
...@@ -322,19 +323,11 @@ static void omap2_mcspi_tx_dma(struct spi_device *spi, ...@@ -322,19 +323,11 @@ static void omap2_mcspi_tx_dma(struct spi_device *spi,
struct omap2_mcspi *mcspi; struct omap2_mcspi *mcspi;
struct omap2_mcspi_dma *mcspi_dma; struct omap2_mcspi_dma *mcspi_dma;
unsigned int count; unsigned int count;
u8 * rx;
const u8 * tx;
void __iomem *chstat_reg;
struct omap2_mcspi_cs *cs = spi->controller_state;
mcspi = spi_master_get_devdata(spi->master); mcspi = spi_master_get_devdata(spi->master);
mcspi_dma = &mcspi->dma_channels[spi->chip_select]; mcspi_dma = &mcspi->dma_channels[spi->chip_select];
count = xfer->len; count = xfer->len;
rx = xfer->rx_buf;
tx = xfer->tx_buf;
chstat_reg = cs->base + OMAP2_MCSPI_CHSTAT0;
if (mcspi_dma->dma_tx) { if (mcspi_dma->dma_tx) {
struct dma_async_tx_descriptor *tx; struct dma_async_tx_descriptor *tx;
struct scatterlist sg; struct scatterlist sg;
...@@ -358,19 +351,6 @@ static void omap2_mcspi_tx_dma(struct spi_device *spi, ...@@ -358,19 +351,6 @@ static void omap2_mcspi_tx_dma(struct spi_device *spi,
dma_async_issue_pending(mcspi_dma->dma_tx); dma_async_issue_pending(mcspi_dma->dma_tx);
omap2_mcspi_set_dma_req(spi, 0, 1); omap2_mcspi_set_dma_req(spi, 0, 1);
wait_for_completion(&mcspi_dma->dma_tx_completion);
dma_unmap_single(mcspi->dev, xfer->tx_dma, count,
DMA_TO_DEVICE);
/* for TX_ONLY mode, be sure all words have shifted out */
if (rx == NULL) {
if (mcspi_wait_for_reg_bit(chstat_reg,
OMAP2_MCSPI_CHSTAT_TXS) < 0)
dev_err(&spi->dev, "TXS timed out\n");
else if (mcspi_wait_for_reg_bit(chstat_reg,
OMAP2_MCSPI_CHSTAT_EOT) < 0)
dev_err(&spi->dev, "EOT timed out\n");
}
} }
static unsigned static unsigned
...@@ -491,6 +471,7 @@ omap2_mcspi_txrx_dma(struct spi_device *spi, struct spi_transfer *xfer) ...@@ -491,6 +471,7 @@ omap2_mcspi_txrx_dma(struct spi_device *spi, struct spi_transfer *xfer)
struct dma_slave_config cfg; struct dma_slave_config cfg;
enum dma_slave_buswidth width; enum dma_slave_buswidth width;
unsigned es; unsigned es;
void __iomem *chstat_reg;
mcspi = spi_master_get_devdata(spi->master); mcspi = spi_master_get_devdata(spi->master);
mcspi_dma = &mcspi->dma_channels[spi->chip_select]; mcspi_dma = &mcspi->dma_channels[spi->chip_select];
...@@ -525,8 +506,24 @@ omap2_mcspi_txrx_dma(struct spi_device *spi, struct spi_transfer *xfer) ...@@ -525,8 +506,24 @@ omap2_mcspi_txrx_dma(struct spi_device *spi, struct spi_transfer *xfer)
omap2_mcspi_tx_dma(spi, xfer, cfg); omap2_mcspi_tx_dma(spi, xfer, cfg);
if (rx != NULL) if (rx != NULL)
return omap2_mcspi_rx_dma(spi, xfer, cfg, es); count = omap2_mcspi_rx_dma(spi, xfer, cfg, es);
if (tx != NULL) {
chstat_reg = cs->base + OMAP2_MCSPI_CHSTAT0;
wait_for_completion(&mcspi_dma->dma_tx_completion);
dma_unmap_single(mcspi->dev, xfer->tx_dma, xfer->len,
DMA_TO_DEVICE);
/* for TX_ONLY mode, be sure all words have shifted out */
if (rx == NULL) {
if (mcspi_wait_for_reg_bit(chstat_reg,
OMAP2_MCSPI_CHSTAT_TXS) < 0)
dev_err(&spi->dev, "TXS timed out\n");
else if (mcspi_wait_for_reg_bit(chstat_reg,
OMAP2_MCSPI_CHSTAT_EOT) < 0)
dev_err(&spi->dev, "EOT timed out\n");
}
}
return count; return count;
} }
...@@ -764,8 +761,15 @@ static int omap2_mcspi_setup_transfer(struct spi_device *spi, ...@@ -764,8 +761,15 @@ static int omap2_mcspi_setup_transfer(struct spi_device *spi,
/* standard 4-wire master mode: SCK, MOSI/out, MISO/in, nCS /* standard 4-wire master mode: SCK, MOSI/out, MISO/in, nCS
* REVISIT: this controller could support SPI_3WIRE mode. * REVISIT: this controller could support SPI_3WIRE mode.
*/ */
l &= ~(OMAP2_MCSPI_CHCONF_IS|OMAP2_MCSPI_CHCONF_DPE1); if (mcspi->pin_dir == MCSPI_PINDIR_D0_IN_D1_OUT) {
l |= OMAP2_MCSPI_CHCONF_DPE0; l &= ~OMAP2_MCSPI_CHCONF_IS;
l &= ~OMAP2_MCSPI_CHCONF_DPE1;
l |= OMAP2_MCSPI_CHCONF_DPE0;
} else {
l |= OMAP2_MCSPI_CHCONF_IS;
l |= OMAP2_MCSPI_CHCONF_DPE1;
l &= ~OMAP2_MCSPI_CHCONF_DPE0;
}
/* wordlength */ /* wordlength */
l &= ~OMAP2_MCSPI_CHCONF_WL_MASK; l &= ~OMAP2_MCSPI_CHCONF_WL_MASK;
...@@ -1166,6 +1170,11 @@ static int __devinit omap2_mcspi_probe(struct platform_device *pdev) ...@@ -1166,6 +1170,11 @@ static int __devinit omap2_mcspi_probe(struct platform_device *pdev)
master->cleanup = omap2_mcspi_cleanup; master->cleanup = omap2_mcspi_cleanup;
master->dev.of_node = node; master->dev.of_node = node;
dev_set_drvdata(&pdev->dev, master);
mcspi = spi_master_get_devdata(master);
mcspi->master = master;
match = of_match_device(omap_mcspi_of_match, &pdev->dev); match = of_match_device(omap_mcspi_of_match, &pdev->dev);
if (match) { if (match) {
u32 num_cs = 1; /* default number of chipselect */ u32 num_cs = 1; /* default number of chipselect */
...@@ -1174,19 +1183,17 @@ static int __devinit omap2_mcspi_probe(struct platform_device *pdev) ...@@ -1174,19 +1183,17 @@ static int __devinit omap2_mcspi_probe(struct platform_device *pdev)
of_property_read_u32(node, "ti,spi-num-cs", &num_cs); of_property_read_u32(node, "ti,spi-num-cs", &num_cs);
master->num_chipselect = num_cs; master->num_chipselect = num_cs;
master->bus_num = bus_num++; master->bus_num = bus_num++;
if (of_get_property(node, "ti,pindir-d0-out-d1-in", NULL))
mcspi->pin_dir = MCSPI_PINDIR_D0_OUT_D1_IN;
} else { } else {
pdata = pdev->dev.platform_data; pdata = pdev->dev.platform_data;
master->num_chipselect = pdata->num_cs; master->num_chipselect = pdata->num_cs;
if (pdev->id != -1) if (pdev->id != -1)
master->bus_num = pdev->id; master->bus_num = pdev->id;
mcspi->pin_dir = pdata->pin_dir;
} }
regs_offset = pdata->regs_offset; regs_offset = pdata->regs_offset;
dev_set_drvdata(&pdev->dev, master);
mcspi = spi_master_get_devdata(master);
mcspi->master = master;
r = platform_get_resource(pdev, IORESOURCE_MEM, 0); r = platform_get_resource(pdev, IORESOURCE_MEM, 0);
if (r == NULL) { if (r == NULL) {
status = -ENODEV; status = -ENODEV;
......
...@@ -371,6 +371,7 @@ struct pl022 { ...@@ -371,6 +371,7 @@ struct pl022 {
/* Two optional pin states - default & sleep */ /* Two optional pin states - default & sleep */
struct pinctrl *pinctrl; struct pinctrl *pinctrl;
struct pinctrl_state *pins_default; struct pinctrl_state *pins_default;
struct pinctrl_state *pins_idle;
struct pinctrl_state *pins_sleep; struct pinctrl_state *pins_sleep;
struct spi_master *master; struct spi_master *master;
struct pl022_ssp_controller *master_info; struct pl022_ssp_controller *master_info;
...@@ -2116,6 +2117,11 @@ pl022_probe(struct amba_device *adev, const struct amba_id *id) ...@@ -2116,6 +2117,11 @@ pl022_probe(struct amba_device *adev, const struct amba_id *id)
} else } else
dev_err(dev, "could not get default pinstate\n"); dev_err(dev, "could not get default pinstate\n");
pl022->pins_idle = pinctrl_lookup_state(pl022->pinctrl,
PINCTRL_STATE_IDLE);
if (IS_ERR(pl022->pins_idle))
dev_dbg(dev, "could not get idle pinstate\n");
pl022->pins_sleep = pinctrl_lookup_state(pl022->pinctrl, pl022->pins_sleep = pinctrl_lookup_state(pl022->pinctrl,
PINCTRL_STATE_SLEEP); PINCTRL_STATE_SLEEP);
if (IS_ERR(pl022->pins_sleep)) if (IS_ERR(pl022->pins_sleep))
...@@ -2246,10 +2252,9 @@ pl022_probe(struct amba_device *adev, const struct amba_id *id) ...@@ -2246,10 +2252,9 @@ pl022_probe(struct amba_device *adev, const struct amba_id *id)
pm_runtime_set_autosuspend_delay(dev, pm_runtime_set_autosuspend_delay(dev,
platform_info->autosuspend_delay); platform_info->autosuspend_delay);
pm_runtime_use_autosuspend(dev); pm_runtime_use_autosuspend(dev);
pm_runtime_put_autosuspend(dev);
} else {
pm_runtime_put(dev);
} }
pm_runtime_put(dev);
return 0; return 0;
err_spi_register: err_spi_register:
...@@ -2303,35 +2308,47 @@ pl022_remove(struct amba_device *adev) ...@@ -2303,35 +2308,47 @@ pl022_remove(struct amba_device *adev)
* the runtime counterparts to handle external resources like * the runtime counterparts to handle external resources like
* clocks, pins and regulators when going to sleep. * clocks, pins and regulators when going to sleep.
*/ */
static void pl022_suspend_resources(struct pl022 *pl022) static void pl022_suspend_resources(struct pl022 *pl022, bool runtime)
{ {
int ret; int ret;
struct pinctrl_state *pins_state;
clk_disable(pl022->clk); clk_disable(pl022->clk);
pins_state = runtime ? pl022->pins_idle : pl022->pins_sleep;
/* Optionally let pins go into sleep states */ /* Optionally let pins go into sleep states */
if (!IS_ERR(pl022->pins_sleep)) { if (!IS_ERR(pins_state)) {
ret = pinctrl_select_state(pl022->pinctrl, ret = pinctrl_select_state(pl022->pinctrl, pins_state);
pl022->pins_sleep);
if (ret) if (ret)
dev_err(&pl022->adev->dev, dev_err(&pl022->adev->dev, "could not set %s pins\n",
"could not set pins to sleep state\n"); runtime ? "idle" : "sleep");
} }
} }
static void pl022_resume_resources(struct pl022 *pl022) static void pl022_resume_resources(struct pl022 *pl022, bool runtime)
{ {
int ret; int ret;
/* Optionaly enable pins to be muxed in and configured */ /* Optionaly enable pins to be muxed in and configured */
/* First go to the default state */
if (!IS_ERR(pl022->pins_default)) { if (!IS_ERR(pl022->pins_default)) {
ret = pinctrl_select_state(pl022->pinctrl, ret = pinctrl_select_state(pl022->pinctrl, pl022->pins_default);
pl022->pins_default);
if (ret) if (ret)
dev_err(&pl022->adev->dev, dev_err(&pl022->adev->dev,
"could not set default pins\n"); "could not set default pins\n");
} }
if (!runtime) {
/* Then let's idle the pins until the next transfer happens */
if (!IS_ERR(pl022->pins_idle)) {
ret = pinctrl_select_state(pl022->pinctrl,
pl022->pins_idle);
if (ret)
dev_err(&pl022->adev->dev,
"could not set idle pins\n");
}
}
clk_enable(pl022->clk); clk_enable(pl022->clk);
} }
#endif #endif
...@@ -2347,7 +2364,9 @@ static int pl022_suspend(struct device *dev) ...@@ -2347,7 +2364,9 @@ static int pl022_suspend(struct device *dev)
dev_warn(dev, "cannot suspend master\n"); dev_warn(dev, "cannot suspend master\n");
return ret; return ret;
} }
pl022_suspend_resources(pl022);
pm_runtime_get_sync(dev);
pl022_suspend_resources(pl022, false);
dev_dbg(dev, "suspended\n"); dev_dbg(dev, "suspended\n");
return 0; return 0;
...@@ -2358,7 +2377,8 @@ static int pl022_resume(struct device *dev) ...@@ -2358,7 +2377,8 @@ static int pl022_resume(struct device *dev)
struct pl022 *pl022 = dev_get_drvdata(dev); struct pl022 *pl022 = dev_get_drvdata(dev);
int ret; int ret;
pl022_resume_resources(pl022); pl022_resume_resources(pl022, false);
pm_runtime_put(dev);
/* Start the queue running */ /* Start the queue running */
ret = spi_master_resume(pl022->master); ret = spi_master_resume(pl022->master);
...@@ -2376,7 +2396,7 @@ static int pl022_runtime_suspend(struct device *dev) ...@@ -2376,7 +2396,7 @@ static int pl022_runtime_suspend(struct device *dev)
{ {
struct pl022 *pl022 = dev_get_drvdata(dev); struct pl022 *pl022 = dev_get_drvdata(dev);
pl022_suspend_resources(pl022); pl022_suspend_resources(pl022, true);
return 0; return 0;
} }
...@@ -2384,7 +2404,7 @@ static int pl022_runtime_resume(struct device *dev) ...@@ -2384,7 +2404,7 @@ static int pl022_runtime_resume(struct device *dev)
{ {
struct pl022 *pl022 = dev_get_drvdata(dev); struct pl022 *pl022 = dev_get_drvdata(dev);
pl022_resume_resources(pl022); pl022_resume_resources(pl022, true);
return 0; return 0;
} }
#endif #endif
......
...@@ -516,7 +516,7 @@ static void s3c64xx_spi_config(struct s3c64xx_spi_driver_data *sdd) ...@@ -516,7 +516,7 @@ static void s3c64xx_spi_config(struct s3c64xx_spi_driver_data *sdd)
/* Disable Clock */ /* Disable Clock */
if (sdd->port_conf->clk_from_cmu) { if (sdd->port_conf->clk_from_cmu) {
clk_disable(sdd->src_clk); clk_disable_unprepare(sdd->src_clk);
} else { } else {
val = readl(regs + S3C64XX_SPI_CLK_CFG); val = readl(regs + S3C64XX_SPI_CLK_CFG);
val &= ~S3C64XX_SPI_ENCLK_ENABLE; val &= ~S3C64XX_SPI_ENCLK_ENABLE;
...@@ -564,7 +564,7 @@ static void s3c64xx_spi_config(struct s3c64xx_spi_driver_data *sdd) ...@@ -564,7 +564,7 @@ static void s3c64xx_spi_config(struct s3c64xx_spi_driver_data *sdd)
/* There is half-multiplier before the SPI */ /* There is half-multiplier before the SPI */
clk_set_rate(sdd->src_clk, sdd->cur_speed * 2); clk_set_rate(sdd->src_clk, sdd->cur_speed * 2);
/* Enable Clock */ /* Enable Clock */
clk_enable(sdd->src_clk); clk_prepare_enable(sdd->src_clk);
} else { } else {
/* Configure Clock */ /* Configure Clock */
val = readl(regs + S3C64XX_SPI_CLK_CFG); val = readl(regs + S3C64XX_SPI_CLK_CFG);
...@@ -1112,7 +1112,7 @@ static int s3c64xx_spi_parse_dt_gpio(struct s3c64xx_spi_driver_data *sdd) ...@@ -1112,7 +1112,7 @@ static int s3c64xx_spi_parse_dt_gpio(struct s3c64xx_spi_driver_data *sdd)
dev_err(dev, "invalid gpio[%d]: %d\n", idx, gpio); dev_err(dev, "invalid gpio[%d]: %d\n", idx, gpio);
goto free_gpio; goto free_gpio;
} }
sdd->gpios[idx] = gpio;
ret = gpio_request(gpio, "spi-bus"); ret = gpio_request(gpio, "spi-bus");
if (ret) { if (ret) {
dev_err(dev, "gpio [%d] request failed: %d\n", dev_err(dev, "gpio [%d] request failed: %d\n",
...@@ -1302,7 +1302,7 @@ static int __init s3c64xx_spi_probe(struct platform_device *pdev) ...@@ -1302,7 +1302,7 @@ static int __init s3c64xx_spi_probe(struct platform_device *pdev)
goto err3; goto err3;
} }
if (clk_enable(sdd->clk)) { if (clk_prepare_enable(sdd->clk)) {
dev_err(&pdev->dev, "Couldn't enable clock 'spi'\n"); dev_err(&pdev->dev, "Couldn't enable clock 'spi'\n");
ret = -EBUSY; ret = -EBUSY;
goto err4; goto err4;
...@@ -1317,7 +1317,7 @@ static int __init s3c64xx_spi_probe(struct platform_device *pdev) ...@@ -1317,7 +1317,7 @@ static int __init s3c64xx_spi_probe(struct platform_device *pdev)
goto err5; goto err5;
} }
if (clk_enable(sdd->src_clk)) { if (clk_prepare_enable(sdd->src_clk)) {
dev_err(&pdev->dev, "Couldn't enable clock '%s'\n", clk_name); dev_err(&pdev->dev, "Couldn't enable clock '%s'\n", clk_name);
ret = -EBUSY; ret = -EBUSY;
goto err6; goto err6;
...@@ -1361,11 +1361,11 @@ static int __init s3c64xx_spi_probe(struct platform_device *pdev) ...@@ -1361,11 +1361,11 @@ static int __init s3c64xx_spi_probe(struct platform_device *pdev)
err8: err8:
free_irq(irq, sdd); free_irq(irq, sdd);
err7: err7:
clk_disable(sdd->src_clk); clk_disable_unprepare(sdd->src_clk);
err6: err6:
clk_put(sdd->src_clk); clk_put(sdd->src_clk);
err5: err5:
clk_disable(sdd->clk); clk_disable_unprepare(sdd->clk);
err4: err4:
clk_put(sdd->clk); clk_put(sdd->clk);
err3: err3:
...@@ -1393,10 +1393,10 @@ static int s3c64xx_spi_remove(struct platform_device *pdev) ...@@ -1393,10 +1393,10 @@ static int s3c64xx_spi_remove(struct platform_device *pdev)
free_irq(platform_get_irq(pdev, 0), sdd); free_irq(platform_get_irq(pdev, 0), sdd);
clk_disable(sdd->src_clk); clk_disable_unprepare(sdd->src_clk);
clk_put(sdd->src_clk); clk_put(sdd->src_clk);
clk_disable(sdd->clk); clk_disable_unprepare(sdd->clk);
clk_put(sdd->clk); clk_put(sdd->clk);
if (!sdd->cntrlr_info->cfg_gpio && pdev->dev.of_node) if (!sdd->cntrlr_info->cfg_gpio && pdev->dev.of_node)
...@@ -1417,8 +1417,8 @@ static int s3c64xx_spi_suspend(struct device *dev) ...@@ -1417,8 +1417,8 @@ static int s3c64xx_spi_suspend(struct device *dev)
spi_master_suspend(master); spi_master_suspend(master);
/* Disable the clock */ /* Disable the clock */
clk_disable(sdd->src_clk); clk_disable_unprepare(sdd->src_clk);
clk_disable(sdd->clk); clk_disable_unprepare(sdd->clk);
if (!sdd->cntrlr_info->cfg_gpio && dev->of_node) if (!sdd->cntrlr_info->cfg_gpio && dev->of_node)
s3c64xx_spi_dt_gpio_free(sdd); s3c64xx_spi_dt_gpio_free(sdd);
...@@ -1440,8 +1440,8 @@ static int s3c64xx_spi_resume(struct device *dev) ...@@ -1440,8 +1440,8 @@ static int s3c64xx_spi_resume(struct device *dev)
sci->cfg_gpio(); sci->cfg_gpio();
/* Enable the clock */ /* Enable the clock */
clk_enable(sdd->src_clk); clk_prepare_enable(sdd->src_clk);
clk_enable(sdd->clk); clk_prepare_enable(sdd->clk);
s3c64xx_spi_hwinit(sdd, sdd->port_id); s3c64xx_spi_hwinit(sdd, sdd->port_id);
...@@ -1457,8 +1457,8 @@ static int s3c64xx_spi_runtime_suspend(struct device *dev) ...@@ -1457,8 +1457,8 @@ static int s3c64xx_spi_runtime_suspend(struct device *dev)
struct spi_master *master = dev_get_drvdata(dev); struct spi_master *master = dev_get_drvdata(dev);
struct s3c64xx_spi_driver_data *sdd = spi_master_get_devdata(master); struct s3c64xx_spi_driver_data *sdd = spi_master_get_devdata(master);
clk_disable(sdd->clk); clk_disable_unprepare(sdd->clk);
clk_disable(sdd->src_clk); clk_disable_unprepare(sdd->src_clk);
return 0; return 0;
} }
...@@ -1468,8 +1468,8 @@ static int s3c64xx_spi_runtime_resume(struct device *dev) ...@@ -1468,8 +1468,8 @@ static int s3c64xx_spi_runtime_resume(struct device *dev)
struct spi_master *master = dev_get_drvdata(dev); struct spi_master *master = dev_get_drvdata(dev);
struct s3c64xx_spi_driver_data *sdd = spi_master_get_devdata(master); struct s3c64xx_spi_driver_data *sdd = spi_master_get_devdata(master);
clk_enable(sdd->src_clk); clk_prepare_enable(sdd->src_clk);
clk_enable(sdd->clk); clk_prepare_enable(sdd->clk);
return 0; return 0;
} }
......
This diff is collapsed.
This diff is collapsed.
...@@ -1204,7 +1204,7 @@ EXPORT_SYMBOL_GPL(spi_busnum_to_master); ...@@ -1204,7 +1204,7 @@ EXPORT_SYMBOL_GPL(spi_busnum_to_master);
int spi_setup(struct spi_device *spi) int spi_setup(struct spi_device *spi)
{ {
unsigned bad_bits; unsigned bad_bits;
int status; int status = 0;
/* help drivers fail *cleanly* when they need options /* help drivers fail *cleanly* when they need options
* that aren't supported with their current master * that aren't supported with their current master
...@@ -1219,7 +1219,8 @@ int spi_setup(struct spi_device *spi) ...@@ -1219,7 +1219,8 @@ int spi_setup(struct spi_device *spi)
if (!spi->bits_per_word) if (!spi->bits_per_word)
spi->bits_per_word = 8; spi->bits_per_word = 8;
status = spi->master->setup(spi); if (spi->master->setup)
status = spi->master->setup(spi);
dev_dbg(&spi->dev, "setup mode %d, %s%s%s%s" dev_dbg(&spi->dev, "setup mode %d, %s%s%s%s"
"%u bits/w, %u Hz max --> %d\n", "%u bits/w, %u Hz max --> %d\n",
...@@ -1238,6 +1239,7 @@ EXPORT_SYMBOL_GPL(spi_setup); ...@@ -1238,6 +1239,7 @@ EXPORT_SYMBOL_GPL(spi_setup);
static int __spi_async(struct spi_device *spi, struct spi_message *message) static int __spi_async(struct spi_device *spi, struct spi_message *message)
{ {
struct spi_master *master = spi->master; struct spi_master *master = spi->master;
struct spi_transfer *xfer;
/* Half-duplex links include original MicroWire, and ones with /* Half-duplex links include original MicroWire, and ones with
* only one data pin like SPI_3WIRE (switches direction) or where * only one data pin like SPI_3WIRE (switches direction) or where
...@@ -1246,7 +1248,6 @@ static int __spi_async(struct spi_device *spi, struct spi_message *message) ...@@ -1246,7 +1248,6 @@ static int __spi_async(struct spi_device *spi, struct spi_message *message)
*/ */
if ((master->flags & SPI_MASTER_HALF_DUPLEX) if ((master->flags & SPI_MASTER_HALF_DUPLEX)
|| (spi->mode & SPI_3WIRE)) { || (spi->mode & SPI_3WIRE)) {
struct spi_transfer *xfer;
unsigned flags = master->flags; unsigned flags = master->flags;
list_for_each_entry(xfer, &message->transfers, transfer_list) { list_for_each_entry(xfer, &message->transfers, transfer_list) {
...@@ -1259,6 +1260,15 @@ static int __spi_async(struct spi_device *spi, struct spi_message *message) ...@@ -1259,6 +1260,15 @@ static int __spi_async(struct spi_device *spi, struct spi_message *message)
} }
} }
/**
* Set transfer bits_per_word as spi device default if it is not
* set for this transfer.
*/
list_for_each_entry(xfer, &message->transfers, transfer_list) {
if (!xfer->bits_per_word)
xfer->bits_per_word = spi->bits_per_word;
}
message->spi = spi; message->spi = spi;
message->status = -EINPROGRESS; message->status = -EINPROGRESS;
return master->transfer(spi, message); return master->transfer(spi, message);
......
...@@ -31,6 +31,8 @@ ...@@ -31,6 +31,8 @@
#include <linux/mutex.h> #include <linux/mutex.h>
#include <linux/slab.h> #include <linux/slab.h>
#include <linux/compat.h> #include <linux/compat.h>
#include <linux/of.h>
#include <linux/of_device.h>
#include <linux/spi/spi.h> #include <linux/spi/spi.h>
#include <linux/spi/spidev.h> #include <linux/spi/spidev.h>
...@@ -642,10 +644,18 @@ static int __devexit spidev_remove(struct spi_device *spi) ...@@ -642,10 +644,18 @@ static int __devexit spidev_remove(struct spi_device *spi)
return 0; return 0;
} }
static const struct of_device_id spidev_dt_ids[] = {
{ .compatible = "rohm,dh2228fv" },
{},
};
MODULE_DEVICE_TABLE(of, spidev_dt_ids);
static struct spi_driver spidev_spi_driver = { static struct spi_driver spidev_spi_driver = {
.driver = { .driver = {
.name = "spidev", .name = "spidev",
.owner = THIS_MODULE, .owner = THIS_MODULE,
.of_match_table = of_match_ptr(spidev_dt_ids),
}, },
.probe = spidev_probe, .probe = spidev_probe,
.remove = __devexit_p(spidev_remove), .remove = __devexit_p(spidev_remove),
......
...@@ -7,9 +7,13 @@ ...@@ -7,9 +7,13 @@
#define OMAP4_MCSPI_REG_OFFSET 0x100 #define OMAP4_MCSPI_REG_OFFSET 0x100
#define MCSPI_PINDIR_D0_IN_D1_OUT 0
#define MCSPI_PINDIR_D0_OUT_D1_IN 1
struct omap2_mcspi_platform_config { struct omap2_mcspi_platform_config {
unsigned short num_cs; unsigned short num_cs;
unsigned int regs_offset; unsigned int regs_offset;
unsigned int pin_dir:1;
}; };
struct omap2_mcspi_dev_attr { struct omap2_mcspi_dev_attr {
......
/*
* spi-tegra.h: SPI interface for Nvidia Tegra20 SLINK controller.
*
* Copyright (C) 2011 NVIDIA Corporation
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#ifndef _LINUX_SPI_TEGRA_H
#define _LINUX_SPI_TEGRA_H
struct tegra_spi_platform_data {
int dma_req_sel;
unsigned int spi_max_frequency;
};
/*
* Controller data from device to pass some info like
* hw based chip select can be used or not and if yes
* then CS hold and setup time.
*/
struct tegra_spi_device_controller_data {
bool is_hw_based_cs;
int cs_setup_clk_count;
int cs_hold_clk_count;
};
#endif /* _LINUX_SPI_TEGRA_H */
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