diff options
Diffstat (limited to 'drivers/mtd/spi-nor/cadence-quadspi.c')
-rw-r--r-- | drivers/mtd/spi-nor/cadence-quadspi.c | 54 |
1 files changed, 16 insertions, 38 deletions
diff --git a/drivers/mtd/spi-nor/cadence-quadspi.c b/drivers/mtd/spi-nor/cadence-quadspi.c index ea53d2cd84..763858567b 100644 --- a/drivers/mtd/spi-nor/cadence-quadspi.c +++ b/drivers/mtd/spi-nor/cadence-quadspi.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-only /* * Copyright (C) 2015 Pengutronix, Steffen Trumtrar <s.trumtrar@pengutronix.de> * @@ -6,18 +7,6 @@ * Driver for Cadence QSPI Controller * * Copyright Altera Corporation (C) 2012-2014. All rights reserved. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms and conditions of the GNU General Public License, - * version 2, as published by the Free Software Foundation. - * - * This program is distributed in the hope 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, see <http://www.gnu.org/licenses/>. */ #include <clock.h> @@ -51,7 +40,7 @@ struct cqspi_flash_pdata { }; struct cqspi_st { - struct device_d *dev; + struct device *dev; struct clk *l4_mp_clk; struct clk *qspi_clk; unsigned int sclk; @@ -347,8 +336,7 @@ static int cqspi_command_read(struct spi_nor *nor, if (!n_rx || n_rx > CQSPI_STIG_DATA_LEN_MAX || rxbuf == NULL) { dev_err(nor->dev, - "Invalid input argument, len %d rxbuf 0x%08x\n", n_rx, - (unsigned int)rxbuf); + "Invalid input argument, len %d rxbuf 0x%p\n", n_rx, rxbuf); return -EINVAL; } @@ -393,8 +381,7 @@ static __maybe_unused int cqspi_command_write(struct spi_nor *nor, if (n_tx > 4 || (n_tx && txbuf == NULL)) { dev_err(nor->dev, - "Invalid input argument, cmdlen %d txbuf 0x%08x\n", - n_tx, (unsigned int)txbuf); + "Invalid input argument, cmdlen %d txbuf 0x%p\n", n_tx, txbuf); return -EINVAL; } @@ -433,7 +420,7 @@ static int cqspi_indirect_read_setup(struct spi_nor *nor, { struct cqspi_flash_pdata *f_pdata; struct cqspi_st *cqspi = nor->priv; - unsigned int ahb_base = (unsigned int) cqspi->ahb_base; + phys_addr_t ahb_base = virt_to_phys(cqspi->ahb_base); void __iomem *reg_base = cqspi->iobase; unsigned int dummy_clk = 0; unsigned int dummy_bytes; @@ -1012,7 +999,7 @@ static int cqspi_write_reg(struct spi_nor *nor, u8 opcode, u8 *buf, int len) return ret; } -static int cqspi_of_get_flash_pdata(struct device_d *dev, +static int cqspi_of_get_flash_pdata(struct device *dev, struct cqspi_flash_pdata *f_pdata, struct device_node *np) { @@ -1069,8 +1056,8 @@ static int cqspi_of_get_flash_pdata(struct device_d *dev, static int cqspi_parse_dt(struct cqspi_st *cqspi) { - struct device_node *np = cqspi->dev->device_node; - struct device_d *dev = cqspi->dev; + struct device_node *np = cqspi->dev->of_node; + struct device *dev = cqspi->dev; cqspi->is_decoded_cs = of_property_read_bool(np, "cdns,is-decoded-cs"); @@ -1082,7 +1069,7 @@ static int cqspi_parse_dt(struct cqspi_st *cqspi) return 0; } -static int cqspi_setup_flash(struct device_d *dev, +static int cqspi_setup_flash(struct device *dev, struct cqspi_flash_pdata *f_pdata, struct device_node *np) { @@ -1112,7 +1099,7 @@ static int cqspi_setup_flash(struct device_d *dev, dev_set_name(nor->dev, np->name); - nor->dev->device_node = np; + nor->dev->of_node = np; nor->dev->id = DEVICE_ID_SINGLE; nor->dev->parent = dev; ret = register_device(nor->dev); @@ -1163,10 +1150,10 @@ static void cqspi_controller_init(struct cqspi_st *cqspi) cqspi_controller_enable(cqspi); } -static int cqspi_probe(struct device_d *dev) +static int cqspi_probe(struct device *dev) { struct resource *iores; - struct device_node *np = dev->device_node; + struct device_node *np = dev->of_node; struct cqspi_st *cqspi; struct cadence_qspi_platform_data *pdata = dev->platform_data; int ret; @@ -1203,28 +1190,18 @@ static int cqspi_probe(struct device_d *dev) if (IS_ERR(iores)) return PTR_ERR(iores); cqspi->iobase = IOMEM(iores->start); - if (IS_ERR(cqspi->iobase)) { - dev_err(dev, "dev_request_mem_region 0 failed\n"); - ret = PTR_ERR(cqspi->iobase); - goto probe_failed; - } iores = dev_request_mem_resource(dev, 1); if (IS_ERR(iores)) return PTR_ERR(iores); cqspi->ahb_base = IOMEM(iores->start); - if (IS_ERR(cqspi->ahb_base)) { - dev_err(dev, "dev_request_mem_region 0 failed\n"); - ret = PTR_ERR(cqspi->ahb_base); - goto probe_failed; - } cqspi_wait_idle(cqspi); cqspi_controller_init(cqspi); cqspi->current_cs = -1; cqspi->sclk = 0; - if (!dev->device_node) { + if (!dev->of_node) { struct cqspi_flash_pdata *f_pdata; f_pdata = &cqspi->f_pdata[0]; @@ -1234,7 +1211,7 @@ static int cqspi_probe(struct device_d *dev) goto probe_failed; } else { /* Get flash device data */ - for_each_available_child_of_node(dev->device_node, np) { + for_each_available_child_of_node(dev->of_node, np) { struct cqspi_flash_pdata *f_pdata; unsigned int cs; if (of_property_read_u32(np, "reg", &cs)) { @@ -1265,8 +1242,9 @@ static __maybe_unused struct of_device_id cqspi_dt_ids[] = { {.compatible = "cdns,qspi-nor",}, { /* end of table */ } }; +MODULE_DEVICE_TABLE(of, cqspi_dt_ids); -static struct driver_d cqspi_driver = { +static struct driver cqspi_driver = { .name = "cadence_qspi", .probe = cqspi_probe, .of_compatible = DRV_OF_COMPAT(cqspi_dt_ids), |