// SPDX-License-Identifier: GPL-2.0-or-later /* * linux/drivers/video/mmp/hw/mmp_spi.c * using the spi in LCD controler for commands send * * Copyright (C) 2012 Marvell Technology Group Ltd. * Authors: Guoqing Li <ligq@marvell.com> * Lisa Du <cldu@marvell.com> * Zhou Zhu <zzhu3@marvell.com>
*/ #include <linux/errno.h> #include <linux/delay.h> #include <linux/err.h> #include <linux/io.h> #include <linux/spi/spi.h> #include"mmp_ctrl.h"
/** * spi_write - write command to the SPI port * @spi: the SPI device. * @data: can be 8/16/32-bit, MSB justified data to write. * * Wait bus transfer complete IRQ. * The caller is expected to perform the necessary locking. * * Returns: * %-ETIMEDOUT timeout occurred * 0 success
*/ staticinlineint lcd_spi_write(struct spi_device *spi, u32 data)
{ int timeout = 100000, isr, ret = 0;
u32 tmp; void __iomem *reg_base = (void __iomem *)
*(void **) spi_controller_get_devdata(spi->controller);
/* * After set mode it needs some time to pull up the spi signals, * or it would cause the wrong waveform when send spi command, * especially on pxa910h
*/
tmp = readl_relaxed(reg_base + SPU_IOPAD_CONTROL); if ((tmp & CFG_IOPADMODE_MASK) != IOPAD_DUMB18SPI)
writel_relaxed(IOPAD_DUMB18SPI |
(tmp & ~CFG_IOPADMODE_MASK),
reg_base + SPU_IOPAD_CONTROL);
udelay(20); return 0;
}
list_for_each_entry(t, &m->transfers, transfer_list) { switch (spi->bits_per_word) { case 8: for (i = 0; i < t->len; i++)
lcd_spi_write(spi, ((u8 *)t->tx_buf)[i]); break; case 16: for (i = 0; i < t->len/2; i++)
lcd_spi_write(spi, ((u16 *)t->tx_buf)[i]); break; case 32: for (i = 0; i < t->len/4; i++)
lcd_spi_write(spi, ((u32 *)t->tx_buf)[i]); break; default:
dev_err(&spi->dev, "Wrong spi bit length\n");
}
}
m->status = 0; if (m->complete)
m->complete(m->context); return 0;
}
int lcd_spi_register(struct mmphw_ctrl *ctrl)
{ struct spi_controller *ctlr; void **p_regbase; int err;
/* set bus num to 5 to avoid conflict with other spi hosts */
ctlr->bus_num = 5;
ctlr->num_chipselect = 1;
ctlr->setup = lcd_spi_setup;
ctlr->transfer = lcd_spi_one_transfer;
err = spi_register_controller(ctlr); if (err < 0) {
dev_err(ctrl->dev, "unable to register SPI host\n");
spi_controller_put(ctlr); return err;
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.