lkml.org 
[lkml]   [2022]   [May]   [21]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
SubjectRe: [PATCH v3] i2c: add support for microchip fpga i2c controllers
Date
On 21/05/2022 10:48, Wolfram Sang wrote:
> EXTERNAL EMAIL: Do not click links or open attachments unless you know the content is safe
> >
> Hi Conor,
>
> driver looks mostly good, but some comments:
>

Hey Wolfram, thanks for the review.
It'll be a few days before I can actually get back to you, but:

---8<---
>
> > + dev_info(&pdev->dev, "default to 100kHz\n");
> > + idev->bus_clk_rate = 100000;
> > + }
> > +
> > + if (idev->bus_clk_rate > 400000)
> > + return dev_err_probe(&pdev->dev, -EINVAL,
> > + "clock-frequency too high: %d\n",
> > + idev->bus_clk_rate);
> > +
> > + ret = devm_request_irq(&pdev->dev, irq, mchp_corei2c_isr, IRQF_SHARED,
> > + pdev->name, idev);
>
> Really SHARED?

Yeah, this driver supports both the hard peripherals & soft FPGA cores.
The hard peripherals do not have shared IRQs, but we don't really have
any control over what way the interrupts are wired for the soft cores.
Worth adding a comment to explain the reason for it being shared?

Thanks,
Conor.

>
> > + if (ret)
> > + return dev_err_probe(&pdev->dev, ret,
> > + "failed to claim irq %d\n", irq);
> > +
> > + ret = clk_prepare_enable(idev->i2c_clk);
> > + if (ret)
> > + return dev_err_probe(&pdev->dev, ret,
> > + "failed to enable clock\n");
> > +
> > + ret = mchp_corei2c_init(idev);
> > + if (ret) {
> > + clk_disable_unprepare(idev->i2c_clk);
> > + return dev_err_probe(&pdev->dev, ret, "failed to program clock divider\n");
> > + }
> > +
> > + i2c_set_adapdata(&idev->adapter, idev);
> > + snprintf(idev->adapter.name, sizeof(idev->adapter.name),
> > + "Microchip I2C hw bus");
>
> Most people add something like the base address here to distinguish
> multiple instances.
>
> > + idev->adapter.owner = THIS_MODULE;
> > + idev->adapter.algo = &mchp_corei2c_algo;
> > + idev->adapter.dev.parent = &pdev->dev;
> > + idev->adapter.dev.of_node = pdev->dev.of_node;
> > +
> > + platform_set_drvdata(pdev, idev);
> > +
> > + ret = i2c_add_adapter(&idev->adapter);
> > + if (ret) {
> > + clk_disable_unprepare(idev->i2c_clk);
> > + return ret;
> > + }
> > +
> > + dev_info(&pdev->dev, "Microchip I2C Probe Complete\n");
> > +
> > + return 0;
> > +}
>
> Rest looks good, Thank you for the submission.
>
> All the best,
>
> Wolfram

\
 
 \ /
  Last update: 2022-05-21 13:34    [W:0.047 / U:0.228 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site