From mboxrd@z Thu Jan 1 00:00:00 1970 From: Florian Fainelli Subject: Re: [PATCH 2/2] spi/bcm63xx: add support for probing through devicetree Date: Thu, 10 Sep 2015 12:19:39 -0700 Message-ID: <55F1D7CB.9020804@openwrt.org> References: <1441898975-22540-1-git-send-email-jogo@openwrt.org> <1441898975-22540-3-git-send-email-jogo@openwrt.org> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit Cc: Mark Brown , Rob Herring , Pawel Moll , Mark Rutland , Ian Campbell , Kumar Gala To: Jonas Gorski , linux-spi-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, devicetree-u79uwXL29TY76Z2rM5mHXA@public.gmane.org Return-path: In-Reply-To: <1441898975-22540-3-git-send-email-jogo-p3rKhJxN3npAfugRpC6u6w@public.gmane.org> Sender: linux-spi-owner-u79uwXL29TY76Z2rM5mHXA@public.gmane.org List-ID: On 10/09/15 08:29, Jonas Gorski wrote: > Add required binding support to probe through device tree. > > Use the compatible instead of the resource size for identifiying the > block type, and allow reducing the number of cs lines through OF. This looks good to me, since this builds on top of your other 6 patches, the end-result might be different, especially if we end-up using platform_device_id as suggested. Other than that: Reviewed-by: Florian Fainelli Thanks for doing this! > > Signed-off-by: Jonas Gorski > --- > drivers/spi/spi-bcm63xx.c | 56 +++++++++++++++++++++++++++++++++++------------ > 1 file changed, 42 insertions(+), 14 deletions(-) > > diff --git a/drivers/spi/spi-bcm63xx.c b/drivers/spi/spi-bcm63xx.c > index 42f33bc..ec094b1 100644 > --- a/drivers/spi/spi-bcm63xx.c > +++ b/drivers/spi/spi-bcm63xx.c > @@ -26,6 +26,7 @@ > #include > #include > #include > +#include > > /* BCM 6338/6348 SPI core */ > #define SPI_6348_RSET_SIZE 64 > @@ -465,6 +466,12 @@ static const unsigned long bcm6358_spi_reg_offsets[] = { > [SPI_MSG_DATA_SIZE] = SPI_6358_MSG_DATA_SIZE, > }; > > +static const struct of_device_id bcm63xx_spi_of_match[] = { > + { .compatible = "brcm,bcm6348-spi", .data = &bcm6348_spi_reg_offsets }, > + { .compatible = "brcm,bcm6358-spi", .data = &bcm6358_spi_reg_offsets }, > + { }, > +}; > + > static int bcm63xx_spi_probe(struct platform_device *pdev) > { > struct resource *r; > @@ -474,6 +481,7 @@ static int bcm63xx_spi_probe(struct platform_device *pdev) > struct clk *clk; > struct bcm63xx_spi *bs; > int ret; > + u32 num_cs = BCM63XX_SPI_MAX_CS; > > irq = platform_get_irq(pdev, 0); > if (irq < 0) { > @@ -516,27 +524,46 @@ static int bcm63xx_spi_probe(struct platform_device *pdev) > goto out_err; > } > > - master->bus_num = BCM63XX_SPI_BUS_NUM; > - master->num_chipselect = BCM63XX_SPI_MAX_CS; > master->transfer_one_message = bcm63xx_spi_transfer_one; > master->mode_bits = MODEBITS; > master->bits_per_word_mask = SPI_BPW_MASK(8); > master->auto_runtime_pm = true; > > - switch (resource_size(r)) { > - case SPI_6348_RSET_SIZE: > - bs->reg_offsets = bcm6348_spi_reg_offsets; > - break; > - case SPI_6358_RSET_SIZE: > - bs->reg_offsets = bcm6358_spi_reg_offsets; > - break; > - default: > - ret = -EINVAL; > - dev_err(dev, "unsupported register size: %i\n", > - resource_size(r)); > - goto out_err; > + if (dev->of_node) { > + const struct of_device_id *match; > + > + match = of_match_node(bcm63xx_spi_of_match, dev->of_node); > + if (!match) { > + ret = -EINVAL; > + goto out_err; > + } > + bs->reg_offsets = match->data; > + master->dev.of_node = dev->of_node; > + of_property_read_u32(dev->of_node, "num-cs", &num_cs); > + if (num_cs > BCM63XX_SPI_MAX_CS) { > + dev_warn(dev, "unsupported number of cs (%i), reducing to 8\n", > + num_cs); > + num_cs = BCM63XX_SPI_MAX_CS; > + } > + } else { > + master->bus_num = BCM63XX_SPI_BUS_NUM; > + > + switch (resource_size(r)) { > + case SPI_6348_RSET_SIZE: > + bs->reg_offsets = bcm6348_spi_reg_offsets; > + break; > + case SPI_6358_RSET_SIZE: > + bs->reg_offsets = bcm6358_spi_reg_offsets; > + break; > + default: > + ret = -EINVAL; > + dev_err(dev, "unsupported register size: %i\n", > + resource_size(r)); > + goto out_err; > + } > } > > + master->num_chipselect = num_cs; > bs->msg_type_shift = bs->reg_offsets[SPI_MSG_TYPE_SHIFT]; > bs->msg_ctl_width = bs->reg_offsets[SPI_MSG_CTL_WIDTH]; > bs->fifo_size = bs->reg_offsets[SPI_MSG_DATA_SIZE]; > @@ -621,6 +648,7 @@ static struct platform_driver bcm63xx_spi_driver = { > .driver = { > .name = "bcm63xx-spi", > .pm = &bcm63xx_spi_pm_ops, > + .of_match_table = bcm63xx_spi_of_match, > }, > .probe = bcm63xx_spi_probe, > .remove = bcm63xx_spi_remove, > -- To unsubscribe from this list: send the line "unsubscribe linux-spi" in the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org More majordomo info at http://vger.kernel.org/majordomo-info.html