File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -280,8 +280,10 @@ static int dw_spi_bt1_probe(struct platform_device *pdev)
280280 dws -> bus_num = pdev -> id ;
281281 dws -> reg_io_width = 4 ;
282282 dws -> max_freq = clk_get_rate (dwsbt1 -> clk );
283- if (!dws -> max_freq )
283+ if (!dws -> max_freq ) {
284+ ret = - EINVAL ;
284285 goto err_disable_clk ;
286+ }
285287
286288 init_func = device_get_match_data (& pdev -> dev );
287289 ret = init_func (pdev , dwsbt1 );
Original file line number Diff line number Diff line change @@ -1165,7 +1165,7 @@ static int dspi_init(struct fsl_dspi *dspi)
11651165 unsigned int mcr ;
11661166
11671167 /* Set idle states for all chip select signals to high */
1168- mcr = SPI_MCR_PCSIS (GENMASK (dspi -> ctlr -> num_chipselect - 1 , 0 ));
1168+ mcr = SPI_MCR_PCSIS (GENMASK (dspi -> ctlr -> max_native_cs - 1 , 0 ));
11691169
11701170 if (dspi -> devtype_data -> trans_mode == DSPI_XSPI_MODE )
11711171 mcr |= SPI_MCR_XSPI ;
@@ -1250,7 +1250,7 @@ static int dspi_probe(struct platform_device *pdev)
12501250
12511251 pdata = dev_get_platdata (& pdev -> dev );
12521252 if (pdata ) {
1253- ctlr -> num_chipselect = pdata -> cs_num ;
1253+ ctlr -> num_chipselect = ctlr -> max_native_cs = pdata -> cs_num ;
12541254 ctlr -> bus_num = pdata -> bus_num ;
12551255
12561256 /* Only Coldfire uses platform data */
@@ -1263,7 +1263,7 @@ static int dspi_probe(struct platform_device *pdev)
12631263 dev_err (& pdev -> dev , "can't get spi-num-chipselects\n" );
12641264 goto out_ctlr_put ;
12651265 }
1266- ctlr -> num_chipselect = cs_num ;
1266+ ctlr -> num_chipselect = ctlr -> max_native_cs = cs_num ;
12671267
12681268 of_property_read_u32 (np , "bus-num" , & bus_num );
12691269 ctlr -> bus_num = bus_num ;
Original file line number Diff line number Diff line change @@ -716,10 +716,11 @@ static int of_fsl_spi_probe(struct platform_device *ofdev)
716716 type = fsl_spi_get_type (& ofdev -> dev );
717717 if (type == TYPE_FSL ) {
718718 struct fsl_spi_platform_data * pdata = dev_get_platdata (dev );
719+ bool spisel_boot = false;
719720#if IS_ENABLED (CONFIG_FSL_SOC )
720721 struct mpc8xxx_spi_probe_info * pinfo = to_of_pinfo (pdata );
721- bool spisel_boot = of_property_read_bool (np , "fsl,spisel_boot" );
722722
723+ spisel_boot = of_property_read_bool (np , "fsl,spisel_boot" );
723724 if (spisel_boot ) {
724725 pinfo -> immr_spi_cs = ioremap (get_immrbase () + IMMR_SPI_CS_OFFSET , 4 );
725726 if (!pinfo -> immr_spi_cs )
@@ -734,10 +735,14 @@ static int of_fsl_spi_probe(struct platform_device *ofdev)
734735 * supported on the GRLIB variant.
735736 */
736737 ret = gpiod_count (dev , "cs" );
737- if (ret <= 0 )
738+ if (ret < 0 )
739+ ret = 0 ;
740+ if (ret == 0 && !spisel_boot ) {
738741 pdata -> max_chipselect = 1 ;
739- else
742+ } else {
743+ pdata -> max_chipselect = ret + spisel_boot ;
740744 pdata -> cs_control = fsl_spi_cs_control ;
745+ }
741746 }
742747
743748 ret = of_address_to_resource (np , 0 , & mem );
Original file line number Diff line number Diff line change @@ -3378,7 +3378,8 @@ int spi_setup(struct spi_device *spi)
33783378 if (status )
33793379 return status ;
33803380
3381- if (!spi -> max_speed_hz )
3381+ if (!spi -> max_speed_hz ||
3382+ spi -> max_speed_hz > spi -> controller -> max_speed_hz )
33823383 spi -> max_speed_hz = spi -> controller -> max_speed_hz ;
33833384
33843385 mutex_lock (& spi -> controller -> io_mutex );
You can’t perform that action at this time.
0 commit comments