[RFC linux dev-4.7 1/5] drivers: fsi: Add function to get FSI clock rate
Joel Stanley
joel at jms.id.au
Thu Mar 16 10:33:21 AEDT 2017
On Sat, Mar 11, 2017 at 8:18 AM, Eddie James <eajames at linux.vnet.ibm.com> wrote:
> From: "Edward A. James" <eajames at us.ibm.com>
>
> client drivers (I2C, etc) may need to know FSI bus clock rate.
We need to make sure the device tree bindings expose this.
Are we able to discover the clock rate through reading some registers?
Or is it hardcoded on all systems?
I suggest you put something like this in the device tree under the FSI
node your testing:
fsi_clock {
#clock-cells = <0>;
compatible = "fixed-clock";
clock-frequency = <8333333>;
};
And retrieve the clock from there. This way when we add the code for
determining the clock rate your driver won't need to change.
Cheers,
Joel
>
> Signed-off-by: Edward A. James <eajames at us.ibm.com>
> ---
> drivers/fsi/fsi-core.c | 7 +++++++
> include/linux/fsi.h | 1 +
> 2 files changed, 8 insertions(+)
>
> diff --git a/drivers/fsi/fsi-core.c b/drivers/fsi/fsi-core.c
> index 3d382e6..492c9e9 100644
> --- a/drivers/fsi/fsi-core.c
> +++ b/drivers/fsi/fsi-core.c
> @@ -139,6 +139,13 @@ int fsi_device_peek(struct fsi_device *dev, void *val)
> return fsi_slave_read(dev->slave, addr, val, sizeof(uint32_t));
> }
>
> +unsigned long fsi_device_get_clk_rate(struct fsi_device *dev)
> +{
> + /* TODO: get clk from dts */
> + return 8333333;
> +}
> +EXPORT_SYMBOL_GPL(fsi_device_get_clk_rate);
> +
> static void fsi_device_release(struct device *_device)
> {
> struct fsi_device *device = to_fsi_dev(_device);
> diff --git a/include/linux/fsi.h b/include/linux/fsi.h
> index d22d0c5..57c8fdb 100644
> --- a/include/linux/fsi.h
> +++ b/include/linux/fsi.h
> @@ -35,6 +35,7 @@ extern int fsi_device_read(struct fsi_device *dev, uint32_t addr,
> extern int fsi_device_write(struct fsi_device *dev, uint32_t addr,
> const void *val, size_t size);
> extern int fsi_device_peek(struct fsi_device *dev, void *val);
> +extern unsigned long fsi_device_get_clk_rate(struct fsi_device *dev);
>
> struct fsi_device_id {
> u8 engine_type;
> --
> 1.8.3.1
>
More information about the openbmc
mailing list