Merge remote-tracking branch 'spi/for-5.7' into spi-linus
This commit is contained in:
Коммит
0c0c5b8fab
|
@ -489,22 +489,6 @@ static int spi_engine_probe(struct platform_device *pdev)
|
|||
|
||||
spin_lock_init(&spi_engine->lock);
|
||||
|
||||
spi_engine->base = devm_platform_ioremap_resource(pdev, 0);
|
||||
if (IS_ERR(spi_engine->base)) {
|
||||
ret = PTR_ERR(spi_engine->base);
|
||||
goto err_put_master;
|
||||
}
|
||||
|
||||
version = readl(spi_engine->base + SPI_ENGINE_REG_VERSION);
|
||||
if (SPI_ENGINE_VERSION_MAJOR(version) != 1) {
|
||||
dev_err(&pdev->dev, "Unsupported peripheral version %u.%u.%c\n",
|
||||
SPI_ENGINE_VERSION_MAJOR(version),
|
||||
SPI_ENGINE_VERSION_MINOR(version),
|
||||
SPI_ENGINE_VERSION_PATCH(version));
|
||||
ret = -ENODEV;
|
||||
goto err_put_master;
|
||||
}
|
||||
|
||||
spi_engine->clk = devm_clk_get(&pdev->dev, "s_axi_aclk");
|
||||
if (IS_ERR(spi_engine->clk)) {
|
||||
ret = PTR_ERR(spi_engine->clk);
|
||||
|
@ -525,6 +509,22 @@ static int spi_engine_probe(struct platform_device *pdev)
|
|||
if (ret)
|
||||
goto err_clk_disable;
|
||||
|
||||
spi_engine->base = devm_platform_ioremap_resource(pdev, 0);
|
||||
if (IS_ERR(spi_engine->base)) {
|
||||
ret = PTR_ERR(spi_engine->base);
|
||||
goto err_ref_clk_disable;
|
||||
}
|
||||
|
||||
version = readl(spi_engine->base + SPI_ENGINE_REG_VERSION);
|
||||
if (SPI_ENGINE_VERSION_MAJOR(version) != 1) {
|
||||
dev_err(&pdev->dev, "Unsupported peripheral version %u.%u.%c\n",
|
||||
SPI_ENGINE_VERSION_MAJOR(version),
|
||||
SPI_ENGINE_VERSION_MINOR(version),
|
||||
SPI_ENGINE_VERSION_PATCH(version));
|
||||
ret = -ENODEV;
|
||||
goto err_ref_clk_disable;
|
||||
}
|
||||
|
||||
writel_relaxed(0x00, spi_engine->base + SPI_ENGINE_REG_RESET);
|
||||
writel_relaxed(0xff, spi_engine->base + SPI_ENGINE_REG_INT_PENDING);
|
||||
writel_relaxed(0x00, spi_engine->base + SPI_ENGINE_REG_INT_ENABLE);
|
||||
|
|
|
@ -612,19 +612,15 @@ static int update_qspi_trans_byte_count(struct bcm_qspi *qspi,
|
|||
if (qt->trans->cs_change &&
|
||||
(flags & TRANS_STATUS_BREAK_CS_CHANGE))
|
||||
ret |= TRANS_STATUS_BREAK_CS_CHANGE;
|
||||
if (ret)
|
||||
goto done;
|
||||
|
||||
dev_dbg(&qspi->pdev->dev, "advance msg exit\n");
|
||||
if (bcm_qspi_mspi_transfer_is_last(qspi, qt))
|
||||
ret = TRANS_STATUS_BREAK_EOM;
|
||||
ret |= TRANS_STATUS_BREAK_EOM;
|
||||
else
|
||||
ret = TRANS_STATUS_BREAK_NO_BYTES;
|
||||
ret |= TRANS_STATUS_BREAK_NO_BYTES;
|
||||
|
||||
qt->trans = NULL;
|
||||
}
|
||||
|
||||
done:
|
||||
dev_dbg(&qspi->pdev->dev, "trans %p len %d byte %d ret %x\n",
|
||||
qt->trans, qt->trans ? qt->trans->len : 0, qt->byte, ret);
|
||||
return ret;
|
||||
|
@ -670,7 +666,7 @@ static void read_from_hw(struct bcm_qspi *qspi, int slots)
|
|||
if (buf)
|
||||
buf[tp.byte] = read_rxram_slot_u8(qspi, slot);
|
||||
dev_dbg(&qspi->pdev->dev, "RD %02x\n",
|
||||
buf ? buf[tp.byte] : 0xff);
|
||||
buf ? buf[tp.byte] : 0x0);
|
||||
} else {
|
||||
u16 *buf = tp.trans->rx_buf;
|
||||
|
||||
|
@ -678,7 +674,7 @@ static void read_from_hw(struct bcm_qspi *qspi, int slots)
|
|||
buf[tp.byte / 2] = read_rxram_slot_u16(qspi,
|
||||
slot);
|
||||
dev_dbg(&qspi->pdev->dev, "RD %04x\n",
|
||||
buf ? buf[tp.byte] : 0xffff);
|
||||
buf ? buf[tp.byte / 2] : 0x0);
|
||||
}
|
||||
|
||||
update_qspi_trans_byte_count(qspi, &tp,
|
||||
|
@ -733,13 +729,13 @@ static int write_to_hw(struct bcm_qspi *qspi, struct spi_device *spi)
|
|||
while (!tstatus && slot < MSPI_NUM_CDRAM) {
|
||||
if (tp.trans->bits_per_word <= 8) {
|
||||
const u8 *buf = tp.trans->tx_buf;
|
||||
u8 val = buf ? buf[tp.byte] : 0xff;
|
||||
u8 val = buf ? buf[tp.byte] : 0x00;
|
||||
|
||||
write_txram_slot_u8(qspi, slot, val);
|
||||
dev_dbg(&qspi->pdev->dev, "WR %02x\n", val);
|
||||
} else {
|
||||
const u16 *buf = tp.trans->tx_buf;
|
||||
u16 val = buf ? buf[tp.byte / 2] : 0xffff;
|
||||
u16 val = buf ? buf[tp.byte / 2] : 0x0000;
|
||||
|
||||
write_txram_slot_u16(qspi, slot, val);
|
||||
dev_dbg(&qspi->pdev->dev, "WR %04x\n", val);
|
||||
|
@ -771,7 +767,16 @@ static int write_to_hw(struct bcm_qspi *qspi, struct spi_device *spi)
|
|||
bcm_qspi_write(qspi, MSPI, MSPI_NEWQP, 0);
|
||||
bcm_qspi_write(qspi, MSPI, MSPI_ENDQP, slot - 1);
|
||||
|
||||
if (tstatus & TRANS_STATUS_BREAK_DESELECT) {
|
||||
/*
|
||||
* case 1) EOM =1, cs_change =0: SSb inactive
|
||||
* case 2) EOM =1, cs_change =1: SSb stay active
|
||||
* case 3) EOM =0, cs_change =0: SSb stay active
|
||||
* case 4) EOM =0, cs_change =1: SSb inactive
|
||||
*/
|
||||
if (((tstatus & TRANS_STATUS_BREAK_DESELECT)
|
||||
== TRANS_STATUS_BREAK_CS_CHANGE) ||
|
||||
((tstatus & TRANS_STATUS_BREAK_DESELECT)
|
||||
== TRANS_STATUS_BREAK_EOM)) {
|
||||
mspi_cdram = read_cdram_slot(qspi, slot - 1) &
|
||||
~MSPI_CDRAM_CONT_BIT;
|
||||
write_cdram_slot(qspi, slot - 1, mspi_cdram);
|
||||
|
@ -1222,6 +1227,11 @@ int bcm_qspi_probe(struct platform_device *pdev,
|
|||
}
|
||||
|
||||
qspi = spi_master_get_devdata(master);
|
||||
|
||||
qspi->clk = devm_clk_get_optional(&pdev->dev, NULL);
|
||||
if (IS_ERR(qspi->clk))
|
||||
return PTR_ERR(qspi->clk);
|
||||
|
||||
qspi->pdev = pdev;
|
||||
qspi->trans_pos.trans = NULL;
|
||||
qspi->trans_pos.byte = 0;
|
||||
|
@ -1335,13 +1345,6 @@ int bcm_qspi_probe(struct platform_device *pdev,
|
|||
qspi->soc_intc = NULL;
|
||||
}
|
||||
|
||||
qspi->clk = devm_clk_get(&pdev->dev, NULL);
|
||||
if (IS_ERR(qspi->clk)) {
|
||||
dev_warn(dev, "unable to get clock\n");
|
||||
ret = PTR_ERR(qspi->clk);
|
||||
goto qspi_probe_err;
|
||||
}
|
||||
|
||||
ret = clk_prepare_enable(qspi->clk);
|
||||
if (ret) {
|
||||
dev_err(dev, "failed to prepare clock\n");
|
||||
|
@ -1406,7 +1409,7 @@ static int __maybe_unused bcm_qspi_suspend(struct device *dev)
|
|||
bcm_qspi_read(qspi, BSPI, BSPI_STRAP_OVERRIDE_CTRL);
|
||||
|
||||
spi_master_suspend(qspi->master);
|
||||
clk_disable(qspi->clk);
|
||||
clk_disable_unprepare(qspi->clk);
|
||||
bcm_qspi_hw_uninit(qspi);
|
||||
|
||||
return 0;
|
||||
|
@ -1424,7 +1427,7 @@ static int __maybe_unused bcm_qspi_resume(struct device *dev)
|
|||
qspi->soc_intc->bcm_qspi_int_set(qspi->soc_intc, MSPI_DONE,
|
||||
true);
|
||||
|
||||
ret = clk_enable(qspi->clk);
|
||||
ret = clk_prepare_enable(qspi->clk);
|
||||
if (!ret)
|
||||
spi_master_resume(qspi->master);
|
||||
|
||||
|
|
|
@ -1347,7 +1347,7 @@ static int bcm2835_spi_probe(struct platform_device *pdev)
|
|||
goto out_dma_release;
|
||||
}
|
||||
|
||||
err = devm_spi_register_controller(&pdev->dev, ctlr);
|
||||
err = spi_register_controller(ctlr);
|
||||
if (err) {
|
||||
dev_err(&pdev->dev, "could not register SPI controller: %d\n",
|
||||
err);
|
||||
|
@ -1374,6 +1374,8 @@ static int bcm2835_spi_remove(struct platform_device *pdev)
|
|||
|
||||
bcm2835_debugfs_remove(bs);
|
||||
|
||||
spi_unregister_controller(ctlr);
|
||||
|
||||
/* Clear FIFOs, and disable the HW block */
|
||||
bcm2835_wr(bs, BCM2835_SPI_CS,
|
||||
BCM2835_SPI_CS_CLEAR_RX | BCM2835_SPI_CS_CLEAR_TX);
|
||||
|
|
|
@ -569,7 +569,7 @@ static int bcm2835aux_spi_probe(struct platform_device *pdev)
|
|||
goto out_clk_disable;
|
||||
}
|
||||
|
||||
err = devm_spi_register_master(&pdev->dev, master);
|
||||
err = spi_register_master(master);
|
||||
if (err) {
|
||||
dev_err(&pdev->dev, "could not register SPI master: %d\n", err);
|
||||
goto out_clk_disable;
|
||||
|
@ -593,6 +593,8 @@ static int bcm2835aux_spi_remove(struct platform_device *pdev)
|
|||
|
||||
bcm2835aux_debugfs_remove(bs);
|
||||
|
||||
spi_unregister_master(master);
|
||||
|
||||
bcm2835aux_spi_reset_hw(bs);
|
||||
|
||||
/* disable the HW block by releasing the clock */
|
||||
|
|
|
@ -526,7 +526,7 @@ int dw_spi_add_host(struct device *dev, struct dw_spi *dws)
|
|||
}
|
||||
}
|
||||
|
||||
ret = devm_spi_register_controller(dev, master);
|
||||
ret = spi_register_controller(master);
|
||||
if (ret) {
|
||||
dev_err(&master->dev, "problem registering spi master\n");
|
||||
goto err_dma_exit;
|
||||
|
@ -550,6 +550,8 @@ void dw_spi_remove_host(struct dw_spi *dws)
|
|||
{
|
||||
dw_spi_debugfs_remove(dws);
|
||||
|
||||
spi_unregister_controller(dws->master);
|
||||
|
||||
if (dws->dma_ops && dws->dma_ops->dma_exit)
|
||||
dws->dma_ops->dma_exit(dws);
|
||||
|
||||
|
|
|
@ -31,7 +31,8 @@
|
|||
#include <linux/platform_data/spi-ep93xx.h>
|
||||
|
||||
#define SSPCR0 0x0000
|
||||
#define SSPCR0_MODE_SHIFT 6
|
||||
#define SSPCR0_SPO BIT(6)
|
||||
#define SSPCR0_SPH BIT(7)
|
||||
#define SSPCR0_SCR_SHIFT 8
|
||||
|
||||
#define SSPCR1 0x0004
|
||||
|
@ -159,7 +160,10 @@ static int ep93xx_spi_chip_setup(struct spi_master *master,
|
|||
return err;
|
||||
|
||||
cr0 = div_scr << SSPCR0_SCR_SHIFT;
|
||||
cr0 |= (spi->mode & (SPI_CPHA | SPI_CPOL)) << SSPCR0_MODE_SHIFT;
|
||||
if (spi->mode & SPI_CPOL)
|
||||
cr0 |= SSPCR0_SPO;
|
||||
if (spi->mode & SPI_CPHA)
|
||||
cr0 |= SSPCR0_SPH;
|
||||
cr0 |= dss;
|
||||
|
||||
dev_dbg(&master->dev, "setup: mode %d, cpsr %d, scr %d, dss %d\n",
|
||||
|
|
|
@ -51,6 +51,10 @@ static int spi_mux_select(struct spi_device *spi)
|
|||
struct spi_mux_priv *priv = spi_controller_get_devdata(spi->controller);
|
||||
int ret;
|
||||
|
||||
ret = mux_control_select(priv->mux, spi->chip_select);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
if (priv->current_cs == spi->chip_select)
|
||||
return 0;
|
||||
|
||||
|
@ -62,10 +66,6 @@ static int spi_mux_select(struct spi_device *spi)
|
|||
priv->spi->mode = spi->mode;
|
||||
priv->spi->bits_per_word = spi->bits_per_word;
|
||||
|
||||
ret = mux_control_select(priv->mux, spi->chip_select);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
priv->current_cs = spi->chip_select;
|
||||
|
||||
return 0;
|
||||
|
|
|
@ -1884,7 +1884,7 @@ static int pxa2xx_spi_probe(struct platform_device *pdev)
|
|||
|
||||
/* Register with the SPI framework */
|
||||
platform_set_drvdata(pdev, drv_data);
|
||||
status = devm_spi_register_controller(&pdev->dev, controller);
|
||||
status = spi_register_controller(controller);
|
||||
if (status != 0) {
|
||||
dev_err(&pdev->dev, "problem registering spi controller\n");
|
||||
goto out_error_pm_runtime_enabled;
|
||||
|
@ -1893,7 +1893,6 @@ static int pxa2xx_spi_probe(struct platform_device *pdev)
|
|||
return status;
|
||||
|
||||
out_error_pm_runtime_enabled:
|
||||
pm_runtime_put_noidle(&pdev->dev);
|
||||
pm_runtime_disable(&pdev->dev);
|
||||
|
||||
out_error_clock_enabled:
|
||||
|
@ -1916,6 +1915,8 @@ static int pxa2xx_spi_remove(struct platform_device *pdev)
|
|||
|
||||
pm_runtime_get_sync(&pdev->dev);
|
||||
|
||||
spi_unregister_controller(drv_data->controller);
|
||||
|
||||
/* Disable the SSP at the peripheral and SOC level */
|
||||
pxa2xx_spi_write(drv_data, SSCR0, 0);
|
||||
clk_disable_unprepare(ssp->clk);
|
||||
|
|
|
@ -345,6 +345,6 @@ static struct i2c_driver sc18is602_driver = {
|
|||
|
||||
module_i2c_driver(sc18is602_driver);
|
||||
|
||||
MODULE_DESCRIPTION("SC18IC602/603 SPI Master Driver");
|
||||
MODULE_DESCRIPTION("SC18IS602/603 SPI Master Driver");
|
||||
MODULE_AUTHOR("Guenter Roeck");
|
||||
MODULE_LICENSE("GPL");
|
||||
|
|
|
@ -2111,6 +2111,7 @@ static int acpi_spi_add_resource(struct acpi_resource *ares, void *data)
|
|||
}
|
||||
|
||||
lookup->max_speed_hz = sb->connection_speed;
|
||||
lookup->bits_per_word = sb->data_bit_length;
|
||||
|
||||
if (sb->clock_phase == ACPI_SPI_SECOND_PHASE)
|
||||
lookup->mode |= SPI_CPHA;
|
||||
|
@ -2760,6 +2761,8 @@ void spi_unregister_controller(struct spi_controller *ctlr)
|
|||
struct spi_controller *found;
|
||||
int id = ctlr->bus_num;
|
||||
|
||||
device_for_each_child(&ctlr->dev, NULL, __unregister);
|
||||
|
||||
/* First make sure that this controller was ever added */
|
||||
mutex_lock(&board_lock);
|
||||
found = idr_find(&spi_master_idr, id);
|
||||
|
@ -2772,7 +2775,6 @@ void spi_unregister_controller(struct spi_controller *ctlr)
|
|||
list_del(&ctlr->list);
|
||||
mutex_unlock(&board_lock);
|
||||
|
||||
device_for_each_child(&ctlr->dev, NULL, __unregister);
|
||||
device_unregister(&ctlr->dev);
|
||||
/* free bus id */
|
||||
mutex_lock(&board_lock);
|
||||
|
|
Загрузка…
Ссылка в новой задаче