[PATCH 4/6] spi: add Marvell MVEBU SoC SPI driver
Sascha Hauer
s.hauer at pengutronix.de
Sat Jun 29 05:00:59 EDT 2013
On Fri, Jun 28, 2013 at 08:25:45PM +0200, Sebastian Hesselbarth wrote:
> This adds support for the SPI controller found on Marvell MVEBU SoCs
> (Dove, Kirkwood, Discovery Innovation, and Armada 370/XP). Current driver
> is DT only. Compatible strings are provided for Orion (common denominator),
> Armada 370/XP and Dove SoCs.
>
> Signed-off-by: Sebastian Hesselbarth <sebastian.hesselbarth at gmail.com>
Mostly good, some minor stuff inline.
> +static int mvebu_spi_set_transfer_size(struct mvebu_spi *p, int size)
> +{
> + u32 val;
> +
> + if (size != 8 && size != 16)
> + return -EINVAL;
> +
> + p->data16 = (size == 16);
> +
> + val = readl(p->base + SPI_IF_CONFIG) & ~IF_TRANSFER_2BYTE;
> + if (p->data16)
> + val |= IF_TRANSFER_2BYTE;
> + writel(val, p->base + SPI_IF_CONFIG);
> +
Trailing whitespaces here and elsewhere.
> + return 0;
> +}
> +
> +static int mvebu_spi_set_baudrate(struct mvebu_spi *p, u32 speed)
> +{
> + u32 pscl, val;
> +
> + /* standard prescaler values: 1,2,4,6,...,30 */
> + pscl = DIV_ROUND_UP(clk_get_rate(p->clk), speed);
> + pscl = roundup(pscl, 2);
> +
> + debug("%s: clk = %lu, speed = %u, pscl = %d\n",
> + __func__, clk_get_rate(p->clk), speed, pscl);
Please use dev_dbg and friends in drivers.
> + int ret = 0;
> +
> + match = of_match_node(mvebu_spi_dt_ids, dev->device_node);
> + if (!match)
> + return -EINVAL;
> +
> + priv = xzalloc(sizeof(*priv));
> + priv->base = dev_request_mem_region(dev, 0);
Please check priv->base for validity. I know, most other drivers also
don't do it, but at least new drivers should.
Sascha
--
Pengutronix e.K. | |
Industrial Linux Solutions | http://www.pengutronix.de/ |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 |
Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |
More information about the barebox
mailing list