Message ID | 20210705101645.2040106-3-martin@geanix.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | fpga/mfd/hwmon: Initial support for Silicom N5010 PAC | expand |
On 7/5/21 3:16 AM, Martin Hundebøll wrote: > From: Martin Hundebøll <mhu@silicom.dk> > > The Max10 BMC on the Silicom n5010 PAC is slightly different than the > existing BMCs, so use a dedicated feature revision detect it. > > Signed-off-by: Martin Hundebøll <mhu@silicom.dk> > Reviewed-by: Moritz Fischer <mdf@kernel.org> > --- > > Changes since v3: > * Changed "BMC's" to "BMCs" > * Added Moritz' Reviewed-by > > Changes since v2: > * None > > Changes since v1: > * use feature revision from struct dfl_device instead of reading it > from io-mem > > drivers/spi/spi-altera-dfl.c | 15 +++++++++++++-- > 1 file changed, 13 insertions(+), 2 deletions(-) > > diff --git a/drivers/spi/spi-altera-dfl.c b/drivers/spi/spi-altera-dfl.c > index 3e32e4fe5895..f6cf7c8d9dac 100644 > --- a/drivers/spi/spi-altera-dfl.c > +++ b/drivers/spi/spi-altera-dfl.c > @@ -111,6 +111,13 @@ static struct spi_board_info m10_bmc_info = { > .chip_select = 0, > }; > > +static struct spi_board_info m10_n5010_bmc_info = { > + .modalias = "m10-n5010", > + .max_speed_hz = 12500000, > + .bus_num = 0, > + .chip_select = 0, > +}; Other then the modalias, this is exactly the same as m10_bmc_info. Why not set platform_data? > + > static void config_spi_master(void __iomem *base, struct spi_master *master) > { > u64 v; > @@ -130,6 +137,7 @@ static void config_spi_master(void __iomem *base, struct spi_master *master) > > static int dfl_spi_altera_probe(struct dfl_device *dfl_dev) > { > + struct spi_board_info *board_info = &m10_bmc_info; > struct device *dev = &dfl_dev->dev; > struct spi_master *master; > struct altera_spi *hw; > @@ -172,9 +180,12 @@ static int dfl_spi_altera_probe(struct dfl_device *dfl_dev) > goto exit; > } > > - if (!spi_new_device(master, &m10_bmc_info)) { > + if (dfl_dev->revision == FME_FEATURE_REV_MAX10_SPI_N5010) > + board_info = &m10_n5010_bmc_info; The revision is board parameter, I think this check could be improved. There should be a #define FME_FATURE_REV_MAX10_SPI_D5005 0 And it checked here instead of setting above. And -EINVAL returned if the revision is not known. > + > + if (!spi_new_device(master, board_info)) { > dev_err(dev, "%s failed to create SPI device: %s\n", > - __func__, m10_bmc_info.modalias); > + __func__, board_info->modalias); Why isn't this error handled ? Tom > } > > return 0;
On 06/07/2021 16.56, Tom Rix wrote: >> diff --git a/drivers/spi/spi-altera-dfl.c b/drivers/spi/spi-altera-dfl.c >> index 3e32e4fe5895..f6cf7c8d9dac 100644 >> --- a/drivers/spi/spi-altera-dfl.c >> +++ b/drivers/spi/spi-altera-dfl.c >> @@ -111,6 +111,13 @@ static struct spi_board_info m10_bmc_info = { >> .chip_select = 0, >> }; >> +static struct spi_board_info m10_n5010_bmc_info = { >> + .modalias = "m10-n5010", >> + .max_speed_hz = 12500000, >> + .bus_num = 0, >> + .chip_select = 0, >> +}; > > Other then the modalias, this is exactly the same as m10_bmc_info. > > Why not set platform_data? So like this? +static struct spi_board_info m10_n5010_bmc_info = { + .platform_data = "m10-n5010", + .max_speed_hz = 12500000, + .bus_num = 0, + .chip_select = 0, +}; I don't see how that should improve the situation, but we might allocate the board info on the stack and set modalias dynamically instead? // Martin
On 7/14/21 4:33 AM, Martin Hundebøll wrote: > > > On 06/07/2021 16.56, Tom Rix wrote: >>> diff --git a/drivers/spi/spi-altera-dfl.c >>> b/drivers/spi/spi-altera-dfl.c >>> index 3e32e4fe5895..f6cf7c8d9dac 100644 >>> --- a/drivers/spi/spi-altera-dfl.c >>> +++ b/drivers/spi/spi-altera-dfl.c >>> @@ -111,6 +111,13 @@ static struct spi_board_info m10_bmc_info = { >>> .chip_select = 0, >>> }; >>> +static struct spi_board_info m10_n5010_bmc_info = { >>> + .modalias = "m10-n5010", >>> + .max_speed_hz = 12500000, >>> + .bus_num = 0, >>> + .chip_select = 0, >>> +}; >> >> Other then the modalias, this is exactly the same as m10_bmc_info. >> >> Why not set platform_data? > > So like this? > > +static struct spi_board_info m10_n5010_bmc_info = { > + .platform_data = "m10-n5010", > + .max_speed_hz = 12500000, > + .bus_num = 0, > + .chip_select = 0, > +}; > > I don't see how that should improve the situation, but we might allocate > the board info on the stack and set modalias dynamically instead? No, I mean that instead of have two *bmc_info's generalize the existing one. This could be done by using the as yet unused platform_data field to hold the identity as a bit/enum in an int. Tom > > // Martin >
On 14/07/2021 16.22, Tom Rix wrote: > > On 7/14/21 4:33 AM, Martin Hundebøll wrote: >> >> >> On 06/07/2021 16.56, Tom Rix wrote: >>>> diff --git a/drivers/spi/spi-altera-dfl.c b/drivers/spi/spi-altera-dfl.c >>>> index 3e32e4fe5895..f6cf7c8d9dac 100644 >>>> --- a/drivers/spi/spi-altera-dfl.c >>>> +++ b/drivers/spi/spi-altera-dfl.c >>>> @@ -111,6 +111,13 @@ static struct spi_board_info m10_bmc_info = { >>>> .chip_select = 0, >>>> }; >>>> +static struct spi_board_info m10_n5010_bmc_info = { >>>> + .modalias = "m10-n5010", >>>> + .max_speed_hz = 12500000, >>>> + .bus_num = 0, >>>> + .chip_select = 0, >>>> +}; >>> >>> Other then the modalias, this is exactly the same as m10_bmc_info. >>> >>> Why not set platform_data? >> >> So like this? >> >> +static struct spi_board_info m10_n5010_bmc_info = { >> + .platform_data = "m10-n5010", >> + .max_speed_hz = 12500000, >> + .bus_num = 0, >> + .chip_select = 0, >> +}; >> >> I don't see how that should improve the situation, but we might allocate >> the board info on the stack and set modalias dynamically instead? > > No, I mean that instead of have two *bmc_info's generalize the existing one. > > This could be done by using the as yet unused platform_data field to hold the identity as a bit/enum in an int. But the existing one is global/static, so it would need to be moved to the function/stack, yes? In which case we could as easily keep the existing approach of modalias, and avoid changing both drivers/fpga/dfl-n3000-nios.c and drivers/mfd/intel-m10-bmc.c ... // Martin
diff --git a/drivers/spi/spi-altera-dfl.c b/drivers/spi/spi-altera-dfl.c index 3e32e4fe5895..f6cf7c8d9dac 100644 --- a/drivers/spi/spi-altera-dfl.c +++ b/drivers/spi/spi-altera-dfl.c @@ -111,6 +111,13 @@ static struct spi_board_info m10_bmc_info = { .chip_select = 0, }; +static struct spi_board_info m10_n5010_bmc_info = { + .modalias = "m10-n5010", + .max_speed_hz = 12500000, + .bus_num = 0, + .chip_select = 0, +}; + static void config_spi_master(void __iomem *base, struct spi_master *master) { u64 v; @@ -130,6 +137,7 @@ static void config_spi_master(void __iomem *base, struct spi_master *master) static int dfl_spi_altera_probe(struct dfl_device *dfl_dev) { + struct spi_board_info *board_info = &m10_bmc_info; struct device *dev = &dfl_dev->dev; struct spi_master *master; struct altera_spi *hw; @@ -172,9 +180,12 @@ static int dfl_spi_altera_probe(struct dfl_device *dfl_dev) goto exit; } - if (!spi_new_device(master, &m10_bmc_info)) { + if (dfl_dev->revision == FME_FEATURE_REV_MAX10_SPI_N5010) + board_info = &m10_n5010_bmc_info; + + if (!spi_new_device(master, board_info)) { dev_err(dev, "%s failed to create SPI device: %s\n", - __func__, m10_bmc_info.modalias); + __func__, board_info->modalias); } return 0;