[gpio:gpio-descriptors-spi 5/5] drivers//spi/spi-pl022.c:442:22: error: 'struct pl022' has no member named 'cur_cs'; did you mean 'cur_msg'?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



tree:   https://kernel.googlesource.com/pub/scm/linux/kernel/git/linusw/linux-gpio.git gpio-descriptors-spi
head:   6e5614b6476001adb8ce6e2859bc2ca0a4339398
commit: 6e5614b6476001adb8ce6e2859bc2ca0a4339398 [5/5] slask
config: arm-allmodconfig (attached as .config)
compiler: arm-linux-gnueabi-gcc (GCC) 7.4.0
reproduce:
        wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        git checkout 6e5614b6476001adb8ce6e2859bc2ca0a4339398
        # save the attached .config to linux build tree
        GCC_VERSION=7.4.0 make.cross ARCH=arm 

If you fix the issue, kindly add following tag
Reported-by: kbuild test robot <lkp@xxxxxxxxx>

All errors (new ones prefixed by >>):

   In file included from include/linux/bitops.h:5:0,
                    from include/linux/kernel.h:12,
                    from include/linux/list.h:9,
                    from include/linux/module.h:9,
                    from drivers//spi/spi-pl022.c:17:
   drivers//spi/spi-pl022.c: In function 'pl022_set_cs':
>> drivers//spi/spi-pl022.c:442:22: error: 'struct pl022' has no member named 'cur_cs'; did you mean 'cur_msg'?
      tmp &= ~BIT(pl022->cur_cs);
                         ^
   include/linux/bits.h:8:30: note: in definition of macro 'BIT'
    #define BIT(nr)   (UL(1) << (nr))
                                 ^~
   drivers//spi/spi-pl022.c:444:21: error: 'struct pl022' has no member named 'cur_cs'; did you mean 'cur_msg'?
      tmp |= BIT(pl022->cur_cs);
                        ^
   include/linux/bits.h:8:30: note: in definition of macro 'BIT'
    #define BIT(nr)   (UL(1) << (nr))
                                 ^~
   drivers//spi/spi-pl022.c: In function 'giveback':
>> drivers//spi/spi-pl022.c:493:4: error: implicit declaration of function 'pl022_cs_control'; did you mean 'pl022_set_cs'? [-Werror=implicit-function-declaration]
       pl022_cs_control(pl022, SSP_CHIP_DESELECT);
       ^~~~~~~~~~~~~~~~
       pl022_set_cs
   drivers//spi/spi-pl022.c: In function 'pl022_transfer_one_message':
   drivers//spi/spi-pl022.c:1571:9: error: 'struct pl022' has no member named 'cur_cs'; did you mean 'cur_msg'?
     pl022->cur_cs = pl022->chipselects[msg->spi->chip_select];
            ^~~~~~
            cur_msg
>> drivers//spi/spi-pl022.c:1571:23: error: 'struct pl022' has no member named 'chipselects'
     pl022->cur_cs = pl022->chipselects[msg->spi->chip_select];
                          ^~
   drivers//spi/spi-pl022.c: In function 'pl022_setup':
>> drivers//spi/spi-pl022.c:1852:4: error: implicit declaration of function 'of_property_read_u32' [-Werror=implicit-function-declaration]
       of_property_read_u32(np, "pl022,interface",
       ^~~~~~~~~~~~~~~~~~~~
>> drivers//spi/spi-pl022.c:1914:7: error: implicit declaration of function 'gpio_is_valid'; did you mean 'uuid_is_valid'? [-Werror=implicit-function-declaration]
     if (!gpio_is_valid(pl022->chipselects[spi->chip_select]))
          ^~~~~~~~~~~~~
          uuid_is_valid
   drivers//spi/spi-pl022.c:1914:26: error: 'struct pl022' has no member named 'chipselects'
     if (!gpio_is_valid(pl022->chipselects[spi->chip_select]))
                             ^~
   drivers//spi/spi-pl022.c: In function 'pl022_platform_data_dt_get':
>> drivers//spi/spi-pl022.c:2081:11: error: implicit declaration of function 'of_property_read_bool' [-Werror=implicit-function-declaration]
     pd->rt = of_property_read_bool(np, "pl022,rt");
              ^~~~~~~~~~~~~~~~~~~~~
   drivers//spi/spi-pl022.c: In function 'pl022_probe':
   drivers//spi/spi-pl022.c:2125:7: error: 'struct pl022' has no member named 'chipselects'
     pl022->chipselects = devm_kcalloc(dev, num_cs, sizeof(int),
          ^~
   drivers//spi/spi-pl022.c:2127:12: error: 'struct pl022' has no member named 'chipselects'
     if (!pl022->chipselects) {
               ^~
   drivers//spi/spi-pl022.c:2137:8: warning: statement with no effect [-Wunused-value]
     master->use_gpio_descriptors;
     ~~~~~~^~~~~~~~~~~~~~~~~~~~~~
   drivers//spi/spi-pl022.c:2150:9: error: 'struct pl022' has no member named 'chipselects'
       pl022->chipselects[i] = i;
            ^~
>> drivers//spi/spi-pl022.c:2153:18: error: implicit declaration of function 'of_get_named_gpio'; did you mean 'fwnode_get_named_gpiod'? [-Werror=implicit-function-declaration]
       int cs_gpio = of_get_named_gpio(np, "cs-gpios", i);
                     ^~~~~~~~~~~~~~~~~
                     fwnode_get_named_gpiod
   drivers//spi/spi-pl022.c:2160:9: error: 'struct pl022' has no member named 'chipselects'
       pl022->chipselects[i] = cs_gpio;
            ^~
>> drivers//spi/spi-pl022.c:2163:9: error: implicit declaration of function 'devm_gpio_request'; did you mean 'devm_gpiod_put'? [-Werror=implicit-function-declaration]
        if (devm_gpio_request(dev, cs_gpio, "ssp-pl022"))
            ^~~~~~~~~~~~~~~~~
            devm_gpiod_put
>> drivers//spi/spi-pl022.c:2167:14: error: implicit declaration of function 'gpio_direction_output'; did you mean 'gpiod_direction_output'? [-Werror=implicit-function-declaration]
        else if (gpio_direction_output(cs_gpio, 1))
                 ^~~~~~~~~~~~~~~~~~~~~
                 gpiod_direction_output
   cc1: some warnings being treated as errors

vim +442 drivers//spi/spi-pl022.c

b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09   421  
6e5614b6476001a drivers/spi/spi-pl022.c  Linus Walleij            2019-06-25   422  static void pl022_set_cs(struct spi_device *spi, bool enable)
db4fa45ed3182d8 drivers/spi/spi-pl022.c  Anders Berg              2014-09-17   423  {
6e5614b6476001a drivers/spi/spi-pl022.c  Linus Walleij            2019-06-25   424  	struct pl022 *pl022 = spi_controller_get_devdata(spi->controller);
db4fa45ed3182d8 drivers/spi/spi-pl022.c  Anders Berg              2014-09-17   425  	u32 tmp;
db4fa45ed3182d8 drivers/spi/spi-pl022.c  Anders Berg              2014-09-17   426  
6e5614b6476001a drivers/spi/spi-pl022.c  Linus Walleij            2019-06-25   427  	/*
6e5614b6476001a drivers/spi/spi-pl022.c  Linus Walleij            2019-06-25   428  	 * This callback will ONLY be called of no GPIO descriptors were found
6e5614b6476001a drivers/spi/spi-pl022.c  Linus Walleij            2019-06-25   429  	 * for the device, so we know we are dealing exclusively with variants
6e5614b6476001a drivers/spi/spi-pl022.c  Linus Walleij            2019-06-25   430  	 * that have internal CS control here, but just to be sure: extra check
6e5614b6476001a drivers/spi/spi-pl022.c  Linus Walleij            2019-06-25   431  	 * for now.
6e5614b6476001a drivers/spi/spi-pl022.c  Linus Walleij            2019-06-25   432  	 */
6e5614b6476001a drivers/spi/spi-pl022.c  Linus Walleij            2019-06-25   433  	if (!pl022->vendor->internal_cs_ctrl) {
6e5614b6476001a drivers/spi/spi-pl022.c  Linus Walleij            2019-06-25   434  		dev_err(&spi->dev,
6e5614b6476001a drivers/spi/spi-pl022.c  Linus Walleij            2019-06-25   435  			"called internal CS control on unsupported device\n");
6e5614b6476001a drivers/spi/spi-pl022.c  Linus Walleij            2019-06-25   436  		return;
6e5614b6476001a drivers/spi/spi-pl022.c  Linus Walleij            2019-06-25   437  	}
6e5614b6476001a drivers/spi/spi-pl022.c  Linus Walleij            2019-06-25   438  
6e5614b6476001a drivers/spi/spi-pl022.c  Linus Walleij            2019-06-25   439  	/* We draw a line low here to imply we enable it */
db4fa45ed3182d8 drivers/spi/spi-pl022.c  Anders Berg              2014-09-17   440  	tmp = readw(SSP_CSR(pl022->virtbase));
6e5614b6476001a drivers/spi/spi-pl022.c  Linus Walleij            2019-06-25   441  	if (enable)
db4fa45ed3182d8 drivers/spi/spi-pl022.c  Anders Berg              2014-09-17  @442  		tmp &= ~BIT(pl022->cur_cs);
db4fa45ed3182d8 drivers/spi/spi-pl022.c  Anders Berg              2014-09-17   443  	else
db4fa45ed3182d8 drivers/spi/spi-pl022.c  Anders Berg              2014-09-17  @444  		tmp |= BIT(pl022->cur_cs);
db4fa45ed3182d8 drivers/spi/spi-pl022.c  Anders Berg              2014-09-17   445  	writew(tmp, SSP_CSR(pl022->virtbase));
db4fa45ed3182d8 drivers/spi/spi-pl022.c  Anders Berg              2014-09-17   446  }
db4fa45ed3182d8 drivers/spi/spi-pl022.c  Anders Berg              2014-09-17   447  
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09   448  /**
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09   449   * giveback - current spi_message is over, schedule next message and call
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09   450   * callback of this message. Assumes that caller already
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09   451   * set message->status; dma and pio irqs are blocked
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09   452   * @pl022: SSP driver private data structure
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09   453   */
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09   454  static void giveback(struct pl022 *pl022)
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09   455  {
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09   456  	struct spi_transfer *last_transfer;
8b8d719161c3866 drivers/spi/spi-pl022.c  Virupax Sadashivpetimath 2011-11-10   457  	pl022->next_msg_cs_active = false;
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09   458  
23e2c2aa45a213e drivers/spi/spi-pl022.c  Axel Lin                 2014-02-12   459  	last_transfer = list_last_entry(&pl022->cur_msg->transfers,
23e2c2aa45a213e drivers/spi/spi-pl022.c  Axel Lin                 2014-02-12   460  					struct spi_transfer, transfer_list);
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09   461  
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09   462  	/* Delay if requested before any change in chip select */
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09   463  	if (last_transfer->delay_usecs)
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09   464  		/*
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09   465  		 * FIXME: This runs in interrupt context.
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09   466  		 * Is this really smart?
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09   467  		 */
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09   468  		udelay(last_transfer->delay_usecs);
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09   469  
8b8d719161c3866 drivers/spi/spi-pl022.c  Virupax Sadashivpetimath 2011-11-10   470  	if (!last_transfer->cs_change) {
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09   471  		struct spi_message *next_msg;
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09   472  
8b8d719161c3866 drivers/spi/spi-pl022.c  Virupax Sadashivpetimath 2011-11-10   473  		/*
8b8d719161c3866 drivers/spi/spi-pl022.c  Virupax Sadashivpetimath 2011-11-10   474  		 * cs_change was not set. We can keep the chip select
8b8d719161c3866 drivers/spi/spi-pl022.c  Virupax Sadashivpetimath 2011-11-10   475  		 * enabled if there is message in the queue and it is
8b8d719161c3866 drivers/spi/spi-pl022.c  Virupax Sadashivpetimath 2011-11-10   476  		 * for the same spi device.
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09   477  		 *
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09   478  		 * We cannot postpone this until pump_messages, because
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09   479  		 * after calling msg->complete (below) the driver that
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09   480  		 * sent the current message could be unloaded, which
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09   481  		 * could invalidate the cs_control() callback...
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09   482  		 */
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09   483  		/* get a pointer to the next message, if any */
ffbbdd21329f3e1 drivers/spi/spi-pl022.c  Linus Walleij            2012-02-22   484  		next_msg = spi_get_next_queued_message(pl022->master);
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09   485  
8b8d719161c3866 drivers/spi/spi-pl022.c  Virupax Sadashivpetimath 2011-11-10   486  		/*
8b8d719161c3866 drivers/spi/spi-pl022.c  Virupax Sadashivpetimath 2011-11-10   487  		 * see if the next and current messages point
8b8d719161c3866 drivers/spi/spi-pl022.c  Virupax Sadashivpetimath 2011-11-10   488  		 * to the same spi device.
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09   489  		 */
8b8d719161c3866 drivers/spi/spi-pl022.c  Virupax Sadashivpetimath 2011-11-10   490  		if (next_msg && next_msg->spi != pl022->cur_msg->spi)
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09   491  			next_msg = NULL;
8b8d719161c3866 drivers/spi/spi-pl022.c  Virupax Sadashivpetimath 2011-11-10   492  		if (!next_msg || pl022->cur_msg->state == STATE_ERROR)
f6f46de1063c882 drivers/spi/spi-pl022.c  Roland Stigge            2012-08-22  @493  			pl022_cs_control(pl022, SSP_CHIP_DESELECT);
8b8d719161c3866 drivers/spi/spi-pl022.c  Virupax Sadashivpetimath 2011-11-10   494  		else
8b8d719161c3866 drivers/spi/spi-pl022.c  Virupax Sadashivpetimath 2011-11-10   495  			pl022->next_msg_cs_active = true;
ffbbdd21329f3e1 drivers/spi/spi-pl022.c  Linus Walleij            2012-02-22   496  
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09   497  	}
8b8d719161c3866 drivers/spi/spi-pl022.c  Virupax Sadashivpetimath 2011-11-10   498  
8b8d719161c3866 drivers/spi/spi-pl022.c  Virupax Sadashivpetimath 2011-11-10   499  	pl022->cur_msg = NULL;
8b8d719161c3866 drivers/spi/spi-pl022.c  Virupax Sadashivpetimath 2011-11-10   500  	pl022->cur_transfer = NULL;
8b8d719161c3866 drivers/spi/spi-pl022.c  Virupax Sadashivpetimath 2011-11-10   501  	pl022->cur_chip = NULL;
fd316941cfee1fb drivers/spi/spi-pl022.c  Virupax Sadashivpetimath 2012-06-12   502  
fd316941cfee1fb drivers/spi/spi-pl022.c  Virupax Sadashivpetimath 2012-06-12   503  	/* disable the SPI/SSP operation */
fd316941cfee1fb drivers/spi/spi-pl022.c  Virupax Sadashivpetimath 2012-06-12   504  	writew((readw(SSP_CR1(pl022->virtbase)) &
fd316941cfee1fb drivers/spi/spi-pl022.c  Virupax Sadashivpetimath 2012-06-12   505  		(~SSP_CR1_MASK_SSE)), SSP_CR1(pl022->virtbase));
fd316941cfee1fb drivers/spi/spi-pl022.c  Virupax Sadashivpetimath 2012-06-12   506  
cd6fa8d2ca53cac drivers/spi/spi-pl022.c  Alexander Sverdlin       2015-02-27   507  	spi_finalize_current_message(pl022->master);
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09   508  }
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09   509  
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09   510  /**
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09   511   * flush - flush the FIFO to reach a clean state
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09   512   * @pl022: SSP driver private data structure
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09   513   */
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09   514  static int flush(struct pl022 *pl022)
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09   515  {
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09   516  	unsigned long limit = loops_per_jiffy << 1;
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09   517  
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09   518  	dev_dbg(&pl022->adev->dev, "flush\n");
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09   519  	do {
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09   520  		while (readw(SSP_SR(pl022->virtbase)) & SSP_SR_MASK_RNE)
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09   521  			readw(SSP_DR(pl022->virtbase));
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09   522  	} while ((readw(SSP_SR(pl022->virtbase)) & SSP_SR_MASK_BSY) && limit--);
fc05475f867624d drivers/spi/amba-pl022.c Linus Walleij            2010-01-22   523  
fc05475f867624d drivers/spi/amba-pl022.c Linus Walleij            2010-01-22   524  	pl022->exp_fifo_level = 0;
fc05475f867624d drivers/spi/amba-pl022.c Linus Walleij            2010-01-22   525  
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09   526  	return limit;
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09   527  }
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09   528  
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09   529  /**
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09   530   * restore_state - Load configuration of current chip
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09   531   * @pl022: SSP driver private data structure
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09   532   */
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09   533  static void restore_state(struct pl022 *pl022)
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09   534  {
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09   535  	struct chip_data *chip = pl022->cur_chip;
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09   536  
556f4aeb7d9dfac drivers/spi/amba-pl022.c Linus Walleij            2010-05-05   537  	if (pl022->vendor->extended_cr)
556f4aeb7d9dfac drivers/spi/amba-pl022.c Linus Walleij            2010-05-05   538  		writel(chip->cr0, SSP_CR0(pl022->virtbase));
556f4aeb7d9dfac drivers/spi/amba-pl022.c Linus Walleij            2010-05-05   539  	else
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09   540  		writew(chip->cr0, SSP_CR0(pl022->virtbase));
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09   541  	writew(chip->cr1, SSP_CR1(pl022->virtbase));
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09   542  	writew(chip->dmacr, SSP_DMACR(pl022->virtbase));
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09   543  	writew(chip->cpsr, SSP_CPSR(pl022->virtbase));
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09   544  	writew(DISABLE_ALL_INTERRUPTS, SSP_IMSC(pl022->virtbase));
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09   545  	writew(CLEAR_ALL_INTERRUPTS, SSP_ICR(pl022->virtbase));
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09   546  }
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09   547  
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09   548  /*
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09   549   * Default SSP Register Values
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09   550   */
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09   551  #define DEFAULT_SSP_REG_CR0 ( \
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09   552  	GEN_MASK_BITS(SSP_DATA_BITS_12, SSP_CR0_MASK_DSS, 0)	| \
556f4aeb7d9dfac drivers/spi/amba-pl022.c Linus Walleij            2010-05-05   553  	GEN_MASK_BITS(SSP_INTERFACE_MOTOROLA_SPI, SSP_CR0_MASK_FRF, 4) | \
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09   554  	GEN_MASK_BITS(SSP_CLK_POL_IDLE_LOW, SSP_CR0_MASK_SPO, 6) | \
ee2b805c8eb6459 drivers/spi/amba-pl022.c Linus Walleij            2009-08-15   555  	GEN_MASK_BITS(SSP_CLK_SECOND_EDGE, SSP_CR0_MASK_SPH, 7) | \
556f4aeb7d9dfac drivers/spi/amba-pl022.c Linus Walleij            2010-05-05   556  	GEN_MASK_BITS(SSP_DEFAULT_CLKRATE, SSP_CR0_MASK_SCR, 8) \
556f4aeb7d9dfac drivers/spi/amba-pl022.c Linus Walleij            2010-05-05   557  )
556f4aeb7d9dfac drivers/spi/amba-pl022.c Linus Walleij            2010-05-05   558  
556f4aeb7d9dfac drivers/spi/amba-pl022.c Linus Walleij            2010-05-05   559  /* ST versions have slightly different bit layout */
556f4aeb7d9dfac drivers/spi/amba-pl022.c Linus Walleij            2010-05-05   560  #define DEFAULT_SSP_REG_CR0_ST ( \
556f4aeb7d9dfac drivers/spi/amba-pl022.c Linus Walleij            2010-05-05   561  	GEN_MASK_BITS(SSP_DATA_BITS_12, SSP_CR0_MASK_DSS_ST, 0)	| \
556f4aeb7d9dfac drivers/spi/amba-pl022.c Linus Walleij            2010-05-05   562  	GEN_MASK_BITS(SSP_MICROWIRE_CHANNEL_FULL_DUPLEX, SSP_CR0_MASK_HALFDUP_ST, 5) | \
556f4aeb7d9dfac drivers/spi/amba-pl022.c Linus Walleij            2010-05-05   563  	GEN_MASK_BITS(SSP_CLK_POL_IDLE_LOW, SSP_CR0_MASK_SPO, 6) | \
556f4aeb7d9dfac drivers/spi/amba-pl022.c Linus Walleij            2010-05-05   564  	GEN_MASK_BITS(SSP_CLK_SECOND_EDGE, SSP_CR0_MASK_SPH, 7) | \
556f4aeb7d9dfac drivers/spi/amba-pl022.c Linus Walleij            2010-05-05   565  	GEN_MASK_BITS(SSP_DEFAULT_CLKRATE, SSP_CR0_MASK_SCR, 8) | \
556f4aeb7d9dfac drivers/spi/amba-pl022.c Linus Walleij            2010-05-05   566  	GEN_MASK_BITS(SSP_BITS_8, SSP_CR0_MASK_CSS_ST, 16)	| \
556f4aeb7d9dfac drivers/spi/amba-pl022.c Linus Walleij            2010-05-05   567  	GEN_MASK_BITS(SSP_INTERFACE_MOTOROLA_SPI, SSP_CR0_MASK_FRF_ST, 21) \
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09   568  )
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09   569  
781c7b129b1beb8 drivers/spi/amba-pl022.c Linus Walleij            2010-05-07   570  /* The PL023 version is slightly different again */
781c7b129b1beb8 drivers/spi/amba-pl022.c Linus Walleij            2010-05-07   571  #define DEFAULT_SSP_REG_CR0_ST_PL023 ( \
781c7b129b1beb8 drivers/spi/amba-pl022.c Linus Walleij            2010-05-07   572  	GEN_MASK_BITS(SSP_DATA_BITS_12, SSP_CR0_MASK_DSS_ST, 0)	| \
781c7b129b1beb8 drivers/spi/amba-pl022.c Linus Walleij            2010-05-07   573  	GEN_MASK_BITS(SSP_CLK_POL_IDLE_LOW, SSP_CR0_MASK_SPO, 6) | \
781c7b129b1beb8 drivers/spi/amba-pl022.c Linus Walleij            2010-05-07   574  	GEN_MASK_BITS(SSP_CLK_SECOND_EDGE, SSP_CR0_MASK_SPH, 7) | \
781c7b129b1beb8 drivers/spi/amba-pl022.c Linus Walleij            2010-05-07   575  	GEN_MASK_BITS(SSP_DEFAULT_CLKRATE, SSP_CR0_MASK_SCR, 8) \
781c7b129b1beb8 drivers/spi/amba-pl022.c Linus Walleij            2010-05-07   576  )
781c7b129b1beb8 drivers/spi/amba-pl022.c Linus Walleij            2010-05-07   577  
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09   578  #define DEFAULT_SSP_REG_CR1 ( \
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09   579  	GEN_MASK_BITS(LOOPBACK_DISABLED, SSP_CR1_MASK_LBM, 0) | \
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09   580  	GEN_MASK_BITS(SSP_DISABLED, SSP_CR1_MASK_SSE, 1) | \
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09   581  	GEN_MASK_BITS(SSP_MASTER, SSP_CR1_MASK_MS, 2) | \
556f4aeb7d9dfac drivers/spi/amba-pl022.c Linus Walleij            2010-05-05   582  	GEN_MASK_BITS(DO_NOT_DRIVE_TX, SSP_CR1_MASK_SOD, 3) \
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09   583  )
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09   584  
556f4aeb7d9dfac drivers/spi/amba-pl022.c Linus Walleij            2010-05-05   585  /* ST versions extend this register to use all 16 bits */
556f4aeb7d9dfac drivers/spi/amba-pl022.c Linus Walleij            2010-05-05   586  #define DEFAULT_SSP_REG_CR1_ST ( \
556f4aeb7d9dfac drivers/spi/amba-pl022.c Linus Walleij            2010-05-05   587  	DEFAULT_SSP_REG_CR1 | \
556f4aeb7d9dfac drivers/spi/amba-pl022.c Linus Walleij            2010-05-05   588  	GEN_MASK_BITS(SSP_RX_MSB, SSP_CR1_MASK_RENDN_ST, 4) | \
556f4aeb7d9dfac drivers/spi/amba-pl022.c Linus Walleij            2010-05-05   589  	GEN_MASK_BITS(SSP_TX_MSB, SSP_CR1_MASK_TENDN_ST, 5) | \
556f4aeb7d9dfac drivers/spi/amba-pl022.c Linus Walleij            2010-05-05   590  	GEN_MASK_BITS(SSP_MWIRE_WAIT_ZERO, SSP_CR1_MASK_MWAIT_ST, 6) |\
556f4aeb7d9dfac drivers/spi/amba-pl022.c Linus Walleij            2010-05-05   591  	GEN_MASK_BITS(SSP_RX_1_OR_MORE_ELEM, SSP_CR1_MASK_RXIFLSEL_ST, 7) | \
556f4aeb7d9dfac drivers/spi/amba-pl022.c Linus Walleij            2010-05-05   592  	GEN_MASK_BITS(SSP_TX_1_OR_MORE_EMPTY_LOC, SSP_CR1_MASK_TXIFLSEL_ST, 10) \
556f4aeb7d9dfac drivers/spi/amba-pl022.c Linus Walleij            2010-05-05   593  )
556f4aeb7d9dfac drivers/spi/amba-pl022.c Linus Walleij            2010-05-05   594  
781c7b129b1beb8 drivers/spi/amba-pl022.c Linus Walleij            2010-05-07   595  /*
781c7b129b1beb8 drivers/spi/amba-pl022.c Linus Walleij            2010-05-07   596   * The PL023 variant has further differences: no loopback mode, no microwire
781c7b129b1beb8 drivers/spi/amba-pl022.c Linus Walleij            2010-05-07   597   * support, and a new clock feedback delay setting.
781c7b129b1beb8 drivers/spi/amba-pl022.c Linus Walleij            2010-05-07   598   */
781c7b129b1beb8 drivers/spi/amba-pl022.c Linus Walleij            2010-05-07   599  #define DEFAULT_SSP_REG_CR1_ST_PL023 ( \
781c7b129b1beb8 drivers/spi/amba-pl022.c Linus Walleij            2010-05-07   600  	GEN_MASK_BITS(SSP_DISABLED, SSP_CR1_MASK_SSE, 1) | \
781c7b129b1beb8 drivers/spi/amba-pl022.c Linus Walleij            2010-05-07   601  	GEN_MASK_BITS(SSP_MASTER, SSP_CR1_MASK_MS, 2) | \
781c7b129b1beb8 drivers/spi/amba-pl022.c Linus Walleij            2010-05-07   602  	GEN_MASK_BITS(DO_NOT_DRIVE_TX, SSP_CR1_MASK_SOD, 3) | \
781c7b129b1beb8 drivers/spi/amba-pl022.c Linus Walleij            2010-05-07   603  	GEN_MASK_BITS(SSP_RX_MSB, SSP_CR1_MASK_RENDN_ST, 4) | \
781c7b129b1beb8 drivers/spi/amba-pl022.c Linus Walleij            2010-05-07   604  	GEN_MASK_BITS(SSP_TX_MSB, SSP_CR1_MASK_TENDN_ST, 5) | \
781c7b129b1beb8 drivers/spi/amba-pl022.c Linus Walleij            2010-05-07   605  	GEN_MASK_BITS(SSP_RX_1_OR_MORE_ELEM, SSP_CR1_MASK_RXIFLSEL_ST, 7) | \
781c7b129b1beb8 drivers/spi/amba-pl022.c Linus Walleij            2010-05-07   606  	GEN_MASK_BITS(SSP_TX_1_OR_MORE_EMPTY_LOC, SSP_CR1_MASK_TXIFLSEL_ST, 10) | \
781c7b129b1beb8 drivers/spi/amba-pl022.c Linus Walleij            2010-05-07   607  	GEN_MASK_BITS(SSP_FEEDBACK_CLK_DELAY_NONE, SSP_CR1_MASK_FBCLKDEL_ST, 13) \
781c7b129b1beb8 drivers/spi/amba-pl022.c Linus Walleij            2010-05-07   608  )
556f4aeb7d9dfac drivers/spi/amba-pl022.c Linus Walleij            2010-05-05   609  
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09   610  #define DEFAULT_SSP_REG_CPSR ( \
556f4aeb7d9dfac drivers/spi/amba-pl022.c Linus Walleij            2010-05-05   611  	GEN_MASK_BITS(SSP_DEFAULT_PRESCALE, SSP_CPSR_MASK_CPSDVSR, 0) \
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09   612  )
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09   613  
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09   614  #define DEFAULT_SSP_REG_DMACR (\
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09   615  	GEN_MASK_BITS(SSP_DMA_DISABLED, SSP_DMACR_MASK_RXDMAE, 0) | \
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09   616  	GEN_MASK_BITS(SSP_DMA_DISABLED, SSP_DMACR_MASK_TXDMAE, 1) \
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09   617  )
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09   618  
781c7b129b1beb8 drivers/spi/amba-pl022.c Linus Walleij            2010-05-07   619  /**
781c7b129b1beb8 drivers/spi/amba-pl022.c Linus Walleij            2010-05-07   620   * load_ssp_default_config - Load default configuration for SSP
781c7b129b1beb8 drivers/spi/amba-pl022.c Linus Walleij            2010-05-07   621   * @pl022: SSP driver private data structure
781c7b129b1beb8 drivers/spi/amba-pl022.c Linus Walleij            2010-05-07   622   */
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09   623  static void load_ssp_default_config(struct pl022 *pl022)
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09   624  {
781c7b129b1beb8 drivers/spi/amba-pl022.c Linus Walleij            2010-05-07   625  	if (pl022->vendor->pl023) {
781c7b129b1beb8 drivers/spi/amba-pl022.c Linus Walleij            2010-05-07   626  		writel(DEFAULT_SSP_REG_CR0_ST_PL023, SSP_CR0(pl022->virtbase));
781c7b129b1beb8 drivers/spi/amba-pl022.c Linus Walleij            2010-05-07   627  		writew(DEFAULT_SSP_REG_CR1_ST_PL023, SSP_CR1(pl022->virtbase));
781c7b129b1beb8 drivers/spi/amba-pl022.c Linus Walleij            2010-05-07   628  	} else if (pl022->vendor->extended_cr) {
556f4aeb7d9dfac drivers/spi/amba-pl022.c Linus Walleij            2010-05-05   629  		writel(DEFAULT_SSP_REG_CR0_ST, SSP_CR0(pl022->virtbase));
556f4aeb7d9dfac drivers/spi/amba-pl022.c Linus Walleij            2010-05-05   630  		writew(DEFAULT_SSP_REG_CR1_ST, SSP_CR1(pl022->virtbase));
556f4aeb7d9dfac drivers/spi/amba-pl022.c Linus Walleij            2010-05-05   631  	} else {
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09   632  		writew(DEFAULT_SSP_REG_CR0, SSP_CR0(pl022->virtbase));
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09   633  		writew(DEFAULT_SSP_REG_CR1, SSP_CR1(pl022->virtbase));
556f4aeb7d9dfac drivers/spi/amba-pl022.c Linus Walleij            2010-05-05   634  	}
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09   635  	writew(DEFAULT_SSP_REG_DMACR, SSP_DMACR(pl022->virtbase));
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09   636  	writew(DEFAULT_SSP_REG_CPSR, SSP_CPSR(pl022->virtbase));
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09   637  	writew(DISABLE_ALL_INTERRUPTS, SSP_IMSC(pl022->virtbase));
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09   638  	writew(CLEAR_ALL_INTERRUPTS, SSP_ICR(pl022->virtbase));
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09   639  }
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09   640  
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09   641  /**
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09   642   * This will write to TX and read from RX according to the parameters
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09   643   * set in pl022.
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09   644   */
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09   645  static void readwriter(struct pl022 *pl022)
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09   646  {
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09   647  
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09   648  	/*
25985edcedea639 drivers/spi/amba-pl022.c Lucas De Marchi          2011-03-30   649  	 * The FIFO depth is different between primecell variants.
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09   650  	 * I believe filling in too much in the FIFO might cause
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09   651  	 * errons in 8bit wide transfers on ARM variants (just 8 words
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09   652  	 * FIFO, means only 8x8 = 64 bits in FIFO) at least.
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09   653  	 *
fc05475f867624d drivers/spi/amba-pl022.c Linus Walleij            2010-01-22   654  	 * To prevent this issue, the TX FIFO is only filled to the
fc05475f867624d drivers/spi/amba-pl022.c Linus Walleij            2010-01-22   655  	 * unused RX FIFO fill length, regardless of what the TX
fc05475f867624d drivers/spi/amba-pl022.c Linus Walleij            2010-01-22   656  	 * FIFO status flag indicates.
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09   657  	 */
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09   658  	dev_dbg(&pl022->adev->dev,
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09   659  		"%s, rx: %p, rxend: %p, tx: %p, txend: %p\n",
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09   660  		__func__, pl022->rx, pl022->rx_end, pl022->tx, pl022->tx_end);
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09   661  
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09   662  	/* Read as much as you can */
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09   663  	while ((readw(SSP_SR(pl022->virtbase)) & SSP_SR_MASK_RNE)
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09   664  	       && (pl022->rx < pl022->rx_end)) {
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09   665  		switch (pl022->read) {
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09   666  		case READING_NULL:
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09   667  			readw(SSP_DR(pl022->virtbase));
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09   668  			break;
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09   669  		case READING_U8:
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09   670  			*(u8 *) (pl022->rx) =
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09   671  				readw(SSP_DR(pl022->virtbase)) & 0xFFU;
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09   672  			break;
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09   673  		case READING_U16:
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09   674  			*(u16 *) (pl022->rx) =
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09   675  				(u16) readw(SSP_DR(pl022->virtbase));
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09   676  			break;
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09   677  		case READING_U32:
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09   678  			*(u32 *) (pl022->rx) =
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09   679  				readl(SSP_DR(pl022->virtbase));
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09   680  			break;
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09   681  		}
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09   682  		pl022->rx += (pl022->cur_chip->n_bytes);
fc05475f867624d drivers/spi/amba-pl022.c Linus Walleij            2010-01-22   683  		pl022->exp_fifo_level--;
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09   684  	}
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09   685  	/*
fc05475f867624d drivers/spi/amba-pl022.c Linus Walleij            2010-01-22   686  	 * Write as much as possible up to the RX FIFO size
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09   687  	 */
fc05475f867624d drivers/spi/amba-pl022.c Linus Walleij            2010-01-22   688  	while ((pl022->exp_fifo_level < pl022->vendor->fifodepth)
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09   689  	       && (pl022->tx < pl022->tx_end)) {
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09   690  		switch (pl022->write) {
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09   691  		case WRITING_NULL:
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09   692  			writew(0x0, SSP_DR(pl022->virtbase));
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09   693  			break;
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09   694  		case WRITING_U8:
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09   695  			writew(*(u8 *) (pl022->tx), SSP_DR(pl022->virtbase));
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09   696  			break;
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09   697  		case WRITING_U16:
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09   698  			writew((*(u16 *) (pl022->tx)), SSP_DR(pl022->virtbase));
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09   699  			break;
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09   700  		case WRITING_U32:
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09   701  			writel(*(u32 *) (pl022->tx), SSP_DR(pl022->virtbase));
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09   702  			break;
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09   703  		}
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09   704  		pl022->tx += (pl022->cur_chip->n_bytes);
fc05475f867624d drivers/spi/amba-pl022.c Linus Walleij            2010-01-22   705  		pl022->exp_fifo_level++;
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09   706  		/*
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09   707  		 * This inner reader takes care of things appearing in the RX
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09   708  		 * FIFO as we're transmitting. This will happen a lot since the
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09   709  		 * clock starts running when you put things into the TX FIFO,
25985edcedea639 drivers/spi/amba-pl022.c Lucas De Marchi          2011-03-30   710  		 * and then things are continuously clocked into the RX FIFO.
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09   711  		 */
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09   712  		while ((readw(SSP_SR(pl022->virtbase)) & SSP_SR_MASK_RNE)
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09   713  		       && (pl022->rx < pl022->rx_end)) {
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09   714  			switch (pl022->read) {
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09   715  			case READING_NULL:
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09   716  				readw(SSP_DR(pl022->virtbase));
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09   717  				break;
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09   718  			case READING_U8:
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09   719  				*(u8 *) (pl022->rx) =
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09   720  					readw(SSP_DR(pl022->virtbase)) & 0xFFU;
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09   721  				break;
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09   722  			case READING_U16:
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09   723  				*(u16 *) (pl022->rx) =
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09   724  					(u16) readw(SSP_DR(pl022->virtbase));
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09   725  				break;
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09   726  			case READING_U32:
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09   727  				*(u32 *) (pl022->rx) =
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09   728  					readl(SSP_DR(pl022->virtbase));
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09   729  				break;
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09   730  			}
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09   731  			pl022->rx += (pl022->cur_chip->n_bytes);
fc05475f867624d drivers/spi/amba-pl022.c Linus Walleij            2010-01-22   732  			pl022->exp_fifo_level--;
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09   733  		}
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09   734  	}
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09   735  	/*
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09   736  	 * When we exit here the TX FIFO should be full and the RX FIFO
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09   737  	 * should be empty
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09   738  	 */
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09   739  }
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09   740  
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09   741  /**
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09   742   * next_transfer - Move to the Next transfer in the current spi message
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09   743   * @pl022: SSP driver private data structure
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09   744   *
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09   745   * This function moves though the linked list of spi transfers in the
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09   746   * current spi message and returns with the state of current spi
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09   747   * message i.e whether its last transfer is done(STATE_DONE) or
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09   748   * Next transfer is ready(STATE_RUNNING)
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09   749   */
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09   750  static void *next_transfer(struct pl022 *pl022)
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09   751  {
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09   752  	struct spi_message *msg = pl022->cur_msg;
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09   753  	struct spi_transfer *trans = pl022->cur_transfer;
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09   754  
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09   755  	/* Move to next transfer */
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09   756  	if (trans->transfer_list.next != &msg->transfers) {
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09   757  		pl022->cur_transfer =
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09   758  		    list_entry(trans->transfer_list.next,
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09   759  			       struct spi_transfer, transfer_list);
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09   760  		return STATE_RUNNING;
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09   761  	}
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09   762  	return STATE_DONE;
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09   763  }
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29   764  
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29   765  /*
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29   766   * This DMA functionality is only compiled in if we have
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29   767   * access to the generic DMA devices/DMA engine.
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29   768   */
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29   769  #ifdef CONFIG_DMA_ENGINE
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29   770  static void unmap_free_dma_scatter(struct pl022 *pl022)
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29   771  {
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29   772  	/* Unmap and free the SG tables */
b729889686afb7d drivers/spi/amba-pl022.c Linus Walleij            2010-12-22   773  	dma_unmap_sg(pl022->dma_tx_channel->device->dev, pl022->sgt_tx.sgl,
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29   774  		     pl022->sgt_tx.nents, DMA_TO_DEVICE);
b729889686afb7d drivers/spi/amba-pl022.c Linus Walleij            2010-12-22   775  	dma_unmap_sg(pl022->dma_rx_channel->device->dev, pl022->sgt_rx.sgl,
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29   776  		     pl022->sgt_rx.nents, DMA_FROM_DEVICE);
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29   777  	sg_free_table(&pl022->sgt_rx);
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29   778  	sg_free_table(&pl022->sgt_tx);
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29   779  }
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29   780  
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29   781  static void dma_callback(void *data)
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29   782  {
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29   783  	struct pl022 *pl022 = data;
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29   784  	struct spi_message *msg = pl022->cur_msg;
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29   785  
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29   786  	BUG_ON(!pl022->sgt_rx.sgl);
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29   787  
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29   788  #ifdef VERBOSE_DEBUG
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29   789  	/*
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29   790  	 * Optionally dump out buffers to inspect contents, this is
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29   791  	 * good if you want to convince yourself that the loopback
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29   792  	 * read/write contents are the same, when adopting to a new
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29   793  	 * DMA engine.
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29   794  	 */
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29   795  	{
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29   796  		struct scatterlist *sg;
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29   797  		unsigned int i;
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29   798  
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29   799  		dma_sync_sg_for_cpu(&pl022->adev->dev,
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29   800  				    pl022->sgt_rx.sgl,
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29   801  				    pl022->sgt_rx.nents,
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29   802  				    DMA_FROM_DEVICE);
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29   803  
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29   804  		for_each_sg(pl022->sgt_rx.sgl, sg, pl022->sgt_rx.nents, i) {
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29   805  			dev_dbg(&pl022->adev->dev, "SPI RX SG ENTRY: %d", i);
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29   806  			print_hex_dump(KERN_ERR, "SPI RX: ",
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29   807  				       DUMP_PREFIX_OFFSET,
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29   808  				       16,
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29   809  				       1,
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29   810  				       sg_virt(sg),
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29   811  				       sg_dma_len(sg),
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29   812  				       1);
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29   813  		}
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29   814  		for_each_sg(pl022->sgt_tx.sgl, sg, pl022->sgt_tx.nents, i) {
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29   815  			dev_dbg(&pl022->adev->dev, "SPI TX SG ENTRY: %d", i);
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29   816  			print_hex_dump(KERN_ERR, "SPI TX: ",
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29   817  				       DUMP_PREFIX_OFFSET,
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29   818  				       16,
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29   819  				       1,
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29   820  				       sg_virt(sg),
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29   821  				       sg_dma_len(sg),
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29   822  				       1);
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29   823  		}
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29   824  	}
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29   825  #endif
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29   826  
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29   827  	unmap_free_dma_scatter(pl022);
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29   828  
25985edcedea639 drivers/spi/amba-pl022.c Lucas De Marchi          2011-03-30   829  	/* Update total bytes transferred */
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29   830  	msg->actual_length += pl022->cur_transfer->len;
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29   831  	/* Move to next transfer */
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29   832  	msg->state = next_transfer(pl022);
c0b07605f1a0285 drivers/spi/spi-pl022.c  Fredrik Ternerot         2018-11-13   833  	if (msg->state != STATE_DONE && pl022->cur_transfer->cs_change)
c0b07605f1a0285 drivers/spi/spi-pl022.c  Fredrik Ternerot         2018-11-13   834  		pl022_cs_control(pl022, SSP_CHIP_DESELECT);
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29   835  	tasklet_schedule(&pl022->pump_transfers);
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29   836  }
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29   837  
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29   838  static void setup_dma_scatter(struct pl022 *pl022,
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29   839  			      void *buffer,
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29   840  			      unsigned int length,
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29   841  			      struct sg_table *sgtab)
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29   842  {
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29   843  	struct scatterlist *sg;
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29   844  	int bytesleft = length;
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29   845  	void *bufp = buffer;
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29   846  	int mapbytes;
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29   847  	int i;
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29   848  
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29   849  	if (buffer) {
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29   850  		for_each_sg(sgtab->sgl, sg, sgtab->nents, i) {
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29   851  			/*
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29   852  			 * If there are less bytes left than what fits
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29   853  			 * in the current page (plus page alignment offset)
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29   854  			 * we just feed in this, else we stuff in as much
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29   855  			 * as we can.
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29   856  			 */
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29   857  			if (bytesleft < (PAGE_SIZE - offset_in_page(bufp)))
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29   858  				mapbytes = bytesleft;
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29   859  			else
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29   860  				mapbytes = PAGE_SIZE - offset_in_page(bufp);
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29   861  			sg_set_page(sg, virt_to_page(bufp),
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29   862  				    mapbytes, offset_in_page(bufp));
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29   863  			bufp += mapbytes;
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29   864  			bytesleft -= mapbytes;
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29   865  			dev_dbg(&pl022->adev->dev,
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29   866  				"set RX/TX target page @ %p, %d bytes, %d left\n",
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29   867  				bufp, mapbytes, bytesleft);
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29   868  		}
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29   869  	} else {
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29   870  		/* Map the dummy buffer on every page */
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29   871  		for_each_sg(sgtab->sgl, sg, sgtab->nents, i) {
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29   872  			if (bytesleft < PAGE_SIZE)
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29   873  				mapbytes = bytesleft;
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29   874  			else
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29   875  				mapbytes = PAGE_SIZE;
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29   876  			sg_set_page(sg, virt_to_page(pl022->dummypage),
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29   877  				    mapbytes, 0);
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29   878  			bytesleft -= mapbytes;
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29   879  			dev_dbg(&pl022->adev->dev,
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29   880  				"set RX/TX to dummy page %d bytes, %d left\n",
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29   881  				mapbytes, bytesleft);
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29   882  
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29   883  		}
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29   884  	}
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29   885  	BUG_ON(bytesleft);
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29   886  }
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29   887  
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29   888  /**
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29   889   * configure_dma - configures the channels for the next transfer
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29   890   * @pl022: SSP driver's private data structure
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29   891   */
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29   892  static int configure_dma(struct pl022 *pl022)
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29   893  {
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29   894  	struct dma_slave_config rx_conf = {
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29   895  		.src_addr = SSP_DR(pl022->phybase),
a485df4b4404379 drivers/spi/spi-pl022.c  Vinod Koul               2011-10-14   896  		.direction = DMA_DEV_TO_MEM,
258aea76f552cc7 drivers/spi/spi-pl022.c  Viresh Kumar             2012-02-01   897  		.device_fc = false,
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29   898  	};
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29   899  	struct dma_slave_config tx_conf = {
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29   900  		.dst_addr = SSP_DR(pl022->phybase),
a485df4b4404379 drivers/spi/spi-pl022.c  Vinod Koul               2011-10-14   901  		.direction = DMA_MEM_TO_DEV,
258aea76f552cc7 drivers/spi/spi-pl022.c  Viresh Kumar             2012-02-01   902  		.device_fc = false,
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29   903  	};
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29   904  	unsigned int pages;
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29   905  	int ret;
082086f2ce53c69 drivers/spi/amba-pl022.c Linus Walleij            2010-12-22   906  	int rx_sglen, tx_sglen;
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29   907  	struct dma_chan *rxchan = pl022->dma_rx_channel;
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29   908  	struct dma_chan *txchan = pl022->dma_tx_channel;
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29   909  	struct dma_async_tx_descriptor *rxdesc;
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29   910  	struct dma_async_tx_descriptor *txdesc;
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29   911  
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29   912  	/* Check that the channels are available */
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29   913  	if (!rxchan || !txchan)
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29   914  		return -ENODEV;
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29   915  
083be3f05371b8f drivers/spi/spi-pl022.c  Linus Walleij            2011-06-16   916  	/*
083be3f05371b8f drivers/spi/spi-pl022.c  Linus Walleij            2011-06-16   917  	 * If supplied, the DMA burstsize should equal the FIFO trigger level.
083be3f05371b8f drivers/spi/spi-pl022.c  Linus Walleij            2011-06-16   918  	 * Notice that the DMA engine uses one-to-one mapping. Since we can
083be3f05371b8f drivers/spi/spi-pl022.c  Linus Walleij            2011-06-16   919  	 * not trigger on 2 elements this needs explicit mapping rather than
083be3f05371b8f drivers/spi/spi-pl022.c  Linus Walleij            2011-06-16   920  	 * calculation.
083be3f05371b8f drivers/spi/spi-pl022.c  Linus Walleij            2011-06-16   921  	 */
083be3f05371b8f drivers/spi/spi-pl022.c  Linus Walleij            2011-06-16   922  	switch (pl022->rx_lev_trig) {
083be3f05371b8f drivers/spi/spi-pl022.c  Linus Walleij            2011-06-16   923  	case SSP_RX_1_OR_MORE_ELEM:
083be3f05371b8f drivers/spi/spi-pl022.c  Linus Walleij            2011-06-16   924  		rx_conf.src_maxburst = 1;
083be3f05371b8f drivers/spi/spi-pl022.c  Linus Walleij            2011-06-16   925  		break;
083be3f05371b8f drivers/spi/spi-pl022.c  Linus Walleij            2011-06-16   926  	case SSP_RX_4_OR_MORE_ELEM:
083be3f05371b8f drivers/spi/spi-pl022.c  Linus Walleij            2011-06-16   927  		rx_conf.src_maxburst = 4;
083be3f05371b8f drivers/spi/spi-pl022.c  Linus Walleij            2011-06-16   928  		break;
083be3f05371b8f drivers/spi/spi-pl022.c  Linus Walleij            2011-06-16   929  	case SSP_RX_8_OR_MORE_ELEM:
083be3f05371b8f drivers/spi/spi-pl022.c  Linus Walleij            2011-06-16   930  		rx_conf.src_maxburst = 8;
083be3f05371b8f drivers/spi/spi-pl022.c  Linus Walleij            2011-06-16   931  		break;
083be3f05371b8f drivers/spi/spi-pl022.c  Linus Walleij            2011-06-16   932  	case SSP_RX_16_OR_MORE_ELEM:
083be3f05371b8f drivers/spi/spi-pl022.c  Linus Walleij            2011-06-16   933  		rx_conf.src_maxburst = 16;
083be3f05371b8f drivers/spi/spi-pl022.c  Linus Walleij            2011-06-16   934  		break;
083be3f05371b8f drivers/spi/spi-pl022.c  Linus Walleij            2011-06-16   935  	case SSP_RX_32_OR_MORE_ELEM:
083be3f05371b8f drivers/spi/spi-pl022.c  Linus Walleij            2011-06-16   936  		rx_conf.src_maxburst = 32;
083be3f05371b8f drivers/spi/spi-pl022.c  Linus Walleij            2011-06-16   937  		break;
083be3f05371b8f drivers/spi/spi-pl022.c  Linus Walleij            2011-06-16   938  	default:
083be3f05371b8f drivers/spi/spi-pl022.c  Linus Walleij            2011-06-16   939  		rx_conf.src_maxburst = pl022->vendor->fifodepth >> 1;
083be3f05371b8f drivers/spi/spi-pl022.c  Linus Walleij            2011-06-16   940  		break;
083be3f05371b8f drivers/spi/spi-pl022.c  Linus Walleij            2011-06-16   941  	}
083be3f05371b8f drivers/spi/spi-pl022.c  Linus Walleij            2011-06-16   942  
083be3f05371b8f drivers/spi/spi-pl022.c  Linus Walleij            2011-06-16   943  	switch (pl022->tx_lev_trig) {
083be3f05371b8f drivers/spi/spi-pl022.c  Linus Walleij            2011-06-16   944  	case SSP_TX_1_OR_MORE_EMPTY_LOC:
083be3f05371b8f drivers/spi/spi-pl022.c  Linus Walleij            2011-06-16   945  		tx_conf.dst_maxburst = 1;
083be3f05371b8f drivers/spi/spi-pl022.c  Linus Walleij            2011-06-16   946  		break;
083be3f05371b8f drivers/spi/spi-pl022.c  Linus Walleij            2011-06-16   947  	case SSP_TX_4_OR_MORE_EMPTY_LOC:
083be3f05371b8f drivers/spi/spi-pl022.c  Linus Walleij            2011-06-16   948  		tx_conf.dst_maxburst = 4;
083be3f05371b8f drivers/spi/spi-pl022.c  Linus Walleij            2011-06-16   949  		break;
083be3f05371b8f drivers/spi/spi-pl022.c  Linus Walleij            2011-06-16   950  	case SSP_TX_8_OR_MORE_EMPTY_LOC:
083be3f05371b8f drivers/spi/spi-pl022.c  Linus Walleij            2011-06-16   951  		tx_conf.dst_maxburst = 8;
083be3f05371b8f drivers/spi/spi-pl022.c  Linus Walleij            2011-06-16   952  		break;
083be3f05371b8f drivers/spi/spi-pl022.c  Linus Walleij            2011-06-16   953  	case SSP_TX_16_OR_MORE_EMPTY_LOC:
083be3f05371b8f drivers/spi/spi-pl022.c  Linus Walleij            2011-06-16   954  		tx_conf.dst_maxburst = 16;
083be3f05371b8f drivers/spi/spi-pl022.c  Linus Walleij            2011-06-16   955  		break;
083be3f05371b8f drivers/spi/spi-pl022.c  Linus Walleij            2011-06-16   956  	case SSP_TX_32_OR_MORE_EMPTY_LOC:
083be3f05371b8f drivers/spi/spi-pl022.c  Linus Walleij            2011-06-16   957  		tx_conf.dst_maxburst = 32;
083be3f05371b8f drivers/spi/spi-pl022.c  Linus Walleij            2011-06-16   958  		break;
083be3f05371b8f drivers/spi/spi-pl022.c  Linus Walleij            2011-06-16   959  	default:
083be3f05371b8f drivers/spi/spi-pl022.c  Linus Walleij            2011-06-16   960  		tx_conf.dst_maxburst = pl022->vendor->fifodepth >> 1;
083be3f05371b8f drivers/spi/spi-pl022.c  Linus Walleij            2011-06-16   961  		break;
083be3f05371b8f drivers/spi/spi-pl022.c  Linus Walleij            2011-06-16   962  	}
083be3f05371b8f drivers/spi/spi-pl022.c  Linus Walleij            2011-06-16   963  
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29   964  	switch (pl022->read) {
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29   965  	case READING_NULL:
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29   966  		/* Use the same as for writing */
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29   967  		rx_conf.src_addr_width = DMA_SLAVE_BUSWIDTH_UNDEFINED;
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29   968  		break;
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29   969  	case READING_U8:
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29   970  		rx_conf.src_addr_width = DMA_SLAVE_BUSWIDTH_1_BYTE;
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29   971  		break;
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29   972  	case READING_U16:
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29   973  		rx_conf.src_addr_width = DMA_SLAVE_BUSWIDTH_2_BYTES;
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29   974  		break;
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29   975  	case READING_U32:
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29   976  		rx_conf.src_addr_width = DMA_SLAVE_BUSWIDTH_4_BYTES;
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29   977  		break;
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29   978  	}
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29   979  
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29   980  	switch (pl022->write) {
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29   981  	case WRITING_NULL:
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29   982  		/* Use the same as for reading */
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29   983  		tx_conf.dst_addr_width = DMA_SLAVE_BUSWIDTH_UNDEFINED;
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29   984  		break;
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29   985  	case WRITING_U8:
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29   986  		tx_conf.dst_addr_width = DMA_SLAVE_BUSWIDTH_1_BYTE;
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29   987  		break;
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29   988  	case WRITING_U16:
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29   989  		tx_conf.dst_addr_width = DMA_SLAVE_BUSWIDTH_2_BYTES;
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29   990  		break;
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29   991  	case WRITING_U32:
bc3f67a3e1b2075 drivers/spi/amba-pl022.c Joe Perches              2010-11-14   992  		tx_conf.dst_addr_width = DMA_SLAVE_BUSWIDTH_4_BYTES;
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29   993  		break;
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29   994  	}
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29   995  
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29   996  	/* SPI pecularity: we need to read and write the same width */
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29   997  	if (rx_conf.src_addr_width == DMA_SLAVE_BUSWIDTH_UNDEFINED)
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29   998  		rx_conf.src_addr_width = tx_conf.dst_addr_width;
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29   999  	if (tx_conf.dst_addr_width == DMA_SLAVE_BUSWIDTH_UNDEFINED)
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29  1000  		tx_conf.dst_addr_width = rx_conf.src_addr_width;
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29  1001  	BUG_ON(rx_conf.src_addr_width != tx_conf.dst_addr_width);
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29  1002  
ecd442fd9e388a3 drivers/spi/amba-pl022.c Linus Walleij            2011-02-08  1003  	dmaengine_slave_config(rxchan, &rx_conf);
ecd442fd9e388a3 drivers/spi/amba-pl022.c Linus Walleij            2011-02-08  1004  	dmaengine_slave_config(txchan, &tx_conf);
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29  1005  
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29  1006  	/* Create sglists for the transfers */
b181565ee6a0f89 drivers/spi/spi-pl022.c  Viresh Kumar             2011-08-10  1007  	pages = DIV_ROUND_UP(pl022->cur_transfer->len, PAGE_SIZE);
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29  1008  	dev_dbg(&pl022->adev->dev, "using %d pages for transfer\n", pages);
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29  1009  
538a18dc189ef5d drivers/spi/spi-pl022.c  Viresh Kumar             2011-08-10  1010  	ret = sg_alloc_table(&pl022->sgt_rx, pages, GFP_ATOMIC);
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29  1011  	if (ret)
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29  1012  		goto err_alloc_rx_sg;
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29  1013  
538a18dc189ef5d drivers/spi/spi-pl022.c  Viresh Kumar             2011-08-10  1014  	ret = sg_alloc_table(&pl022->sgt_tx, pages, GFP_ATOMIC);
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29  1015  	if (ret)
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29  1016  		goto err_alloc_tx_sg;
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29  1017  
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29  1018  	/* Fill in the scatterlists for the RX+TX buffers */
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29  1019  	setup_dma_scatter(pl022, pl022->rx,
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29  1020  			  pl022->cur_transfer->len, &pl022->sgt_rx);
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29  1021  	setup_dma_scatter(pl022, pl022->tx,
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29  1022  			  pl022->cur_transfer->len, &pl022->sgt_tx);
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29  1023  
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29  1024  	/* Map DMA buffers */
082086f2ce53c69 drivers/spi/amba-pl022.c Linus Walleij            2010-12-22  1025  	rx_sglen = dma_map_sg(rxchan->device->dev, pl022->sgt_rx.sgl,
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29  1026  			   pl022->sgt_rx.nents, DMA_FROM_DEVICE);
082086f2ce53c69 drivers/spi/amba-pl022.c Linus Walleij            2010-12-22  1027  	if (!rx_sglen)
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29  1028  		goto err_rx_sgmap;
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29  1029  
082086f2ce53c69 drivers/spi/amba-pl022.c Linus Walleij            2010-12-22  1030  	tx_sglen = dma_map_sg(txchan->device->dev, pl022->sgt_tx.sgl,
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29  1031  			   pl022->sgt_tx.nents, DMA_TO_DEVICE);
082086f2ce53c69 drivers/spi/amba-pl022.c Linus Walleij            2010-12-22  1032  	if (!tx_sglen)
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29  1033  		goto err_tx_sgmap;
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29  1034  
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29  1035  	/* Send both scatterlists */
16052827d98fbc1 drivers/spi/spi-pl022.c  Alexandre Bounine        2012-03-08  1036  	rxdesc = dmaengine_prep_slave_sg(rxchan,
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29  1037  				      pl022->sgt_rx.sgl,
082086f2ce53c69 drivers/spi/amba-pl022.c Linus Walleij            2010-12-22  1038  				      rx_sglen,
a485df4b4404379 drivers/spi/spi-pl022.c  Vinod Koul               2011-10-14  1039  				      DMA_DEV_TO_MEM,
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29  1040  				      DMA_PREP_INTERRUPT | DMA_CTRL_ACK);
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29  1041  	if (!rxdesc)
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29  1042  		goto err_rxdesc;
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29  1043  
16052827d98fbc1 drivers/spi/spi-pl022.c  Alexandre Bounine        2012-03-08  1044  	txdesc = dmaengine_prep_slave_sg(txchan,
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29  1045  				      pl022->sgt_tx.sgl,
082086f2ce53c69 drivers/spi/amba-pl022.c Linus Walleij            2010-12-22  1046  				      tx_sglen,
a485df4b4404379 drivers/spi/spi-pl022.c  Vinod Koul               2011-10-14  1047  				      DMA_MEM_TO_DEV,
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29  1048  				      DMA_PREP_INTERRUPT | DMA_CTRL_ACK);
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29  1049  	if (!txdesc)
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29  1050  		goto err_txdesc;
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29  1051  
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29  1052  	/* Put the callback on the RX transfer only, that should finish last */
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29  1053  	rxdesc->callback = dma_callback;
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29  1054  	rxdesc->callback_param = pl022;
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29  1055  
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29  1056  	/* Submit and fire RX and TX with TX last so we're ready to read! */
ecd442fd9e388a3 drivers/spi/amba-pl022.c Linus Walleij            2011-02-08  1057  	dmaengine_submit(rxdesc);
ecd442fd9e388a3 drivers/spi/amba-pl022.c Linus Walleij            2011-02-08  1058  	dmaengine_submit(txdesc);
ecd442fd9e388a3 drivers/spi/amba-pl022.c Linus Walleij            2011-02-08  1059  	dma_async_issue_pending(rxchan);
ecd442fd9e388a3 drivers/spi/amba-pl022.c Linus Walleij            2011-02-08  1060  	dma_async_issue_pending(txchan);
ffbbdd21329f3e1 drivers/spi/spi-pl022.c  Linus Walleij            2012-02-22  1061  	pl022->dma_running = true;
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29  1062  
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29  1063  	return 0;
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29  1064  
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29  1065  err_txdesc:
ecd442fd9e388a3 drivers/spi/amba-pl022.c Linus Walleij            2011-02-08  1066  	dmaengine_terminate_all(txchan);
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29  1067  err_rxdesc:
ecd442fd9e388a3 drivers/spi/amba-pl022.c Linus Walleij            2011-02-08  1068  	dmaengine_terminate_all(rxchan);
b729889686afb7d drivers/spi/amba-pl022.c Linus Walleij            2010-12-22  1069  	dma_unmap_sg(txchan->device->dev, pl022->sgt_tx.sgl,
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29  1070  		     pl022->sgt_tx.nents, DMA_TO_DEVICE);
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29  1071  err_tx_sgmap:
b729889686afb7d drivers/spi/amba-pl022.c Linus Walleij            2010-12-22  1072  	dma_unmap_sg(rxchan->device->dev, pl022->sgt_rx.sgl,
3ffa6158f002e09 drivers/spi/spi-pl022.c  Ray Jui                  2014-10-09  1073  		     pl022->sgt_rx.nents, DMA_FROM_DEVICE);
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29  1074  err_rx_sgmap:
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29  1075  	sg_free_table(&pl022->sgt_tx);
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29  1076  err_alloc_tx_sg:
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29  1077  	sg_free_table(&pl022->sgt_rx);
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29  1078  err_alloc_rx_sg:
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29  1079  	return -ENOMEM;
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29  1080  }
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29  1081  
fd4a319bc933ae9 drivers/spi/spi-pl022.c  Grant Likely             2012-12-07  1082  static int pl022_dma_probe(struct pl022 *pl022)
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29  1083  {
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29  1084  	dma_cap_mask_t mask;
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29  1085  
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29  1086  	/* Try to acquire a generic DMA engine slave channel */
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29  1087  	dma_cap_zero(mask);
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29  1088  	dma_cap_set(DMA_SLAVE, mask);
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29  1089  	/*
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29  1090  	 * We need both RX and TX channels to do DMA, else do none
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29  1091  	 * of them.
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29  1092  	 */
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29  1093  	pl022->dma_rx_channel = dma_request_channel(mask,
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29  1094  					    pl022->master_info->dma_filter,
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29  1095  					    pl022->master_info->dma_rx_param);
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29  1096  	if (!pl022->dma_rx_channel) {
43c640157d4366a drivers/spi/amba-pl022.c Viresh Kumar             2011-05-16  1097  		dev_dbg(&pl022->adev->dev, "no RX DMA channel!\n");
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29  1098  		goto err_no_rxchan;
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29  1099  	}
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29  1100  
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29  1101  	pl022->dma_tx_channel = dma_request_channel(mask,
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29  1102  					    pl022->master_info->dma_filter,
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29  1103  					    pl022->master_info->dma_tx_param);
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29  1104  	if (!pl022->dma_tx_channel) {
43c640157d4366a drivers/spi/amba-pl022.c Viresh Kumar             2011-05-16  1105  		dev_dbg(&pl022->adev->dev, "no TX DMA channel!\n");
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29  1106  		goto err_no_txchan;
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29  1107  	}
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29  1108  
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29  1109  	pl022->dummypage = kmalloc(PAGE_SIZE, GFP_KERNEL);
77538f4a98dc542 drivers/spi/spi-pl022.c  Jingoo Han               2014-04-29  1110  	if (!pl022->dummypage)
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29  1111  		goto err_no_dummypage;
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29  1112  
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29  1113  	dev_info(&pl022->adev->dev, "setup for DMA on RX %s, TX %s\n",
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29  1114  		 dma_chan_name(pl022->dma_rx_channel),
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29  1115  		 dma_chan_name(pl022->dma_tx_channel));
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29  1116  
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29  1117  	return 0;
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29  1118  
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29  1119  err_no_dummypage:
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29  1120  	dma_release_channel(pl022->dma_tx_channel);
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29  1121  err_no_txchan:
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29  1122  	dma_release_channel(pl022->dma_rx_channel);
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29  1123  	pl022->dma_rx_channel = NULL;
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29  1124  err_no_rxchan:
43c640157d4366a drivers/spi/amba-pl022.c Viresh Kumar             2011-05-16  1125  	dev_err(&pl022->adev->dev,
43c640157d4366a drivers/spi/amba-pl022.c Viresh Kumar             2011-05-16  1126  			"Failed to work in dma mode, work without dma!\n");
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29  1127  	return -ENODEV;
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29  1128  }
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29  1129  
dc715452e914515 drivers/spi/spi-pl022.c  Arnd Bergmann            2013-01-28  1130  static int pl022_dma_autoprobe(struct pl022 *pl022)
dc715452e914515 drivers/spi/spi-pl022.c  Arnd Bergmann            2013-01-28  1131  {
dc715452e914515 drivers/spi/spi-pl022.c  Arnd Bergmann            2013-01-28  1132  	struct device *dev = &pl022->adev->dev;
f3d4bb3342630cd drivers/spi/spi-pl022.c  Rabin Vincent            2015-11-23  1133  	struct dma_chan *chan;
f3d4bb3342630cd drivers/spi/spi-pl022.c  Rabin Vincent            2015-11-23  1134  	int err;
dc715452e914515 drivers/spi/spi-pl022.c  Arnd Bergmann            2013-01-28  1135  
dc715452e914515 drivers/spi/spi-pl022.c  Arnd Bergmann            2013-01-28  1136  	/* automatically configure DMA channels from platform, normally using DT */
f3d4bb3342630cd drivers/spi/spi-pl022.c  Rabin Vincent            2015-11-23  1137  	chan = dma_request_slave_channel_reason(dev, "rx");
f3d4bb3342630cd drivers/spi/spi-pl022.c  Rabin Vincent            2015-11-23  1138  	if (IS_ERR(chan)) {
f3d4bb3342630cd drivers/spi/spi-pl022.c  Rabin Vincent            2015-11-23  1139  		err = PTR_ERR(chan);
dc715452e914515 drivers/spi/spi-pl022.c  Arnd Bergmann            2013-01-28  1140  		goto err_no_rxchan;
f3d4bb3342630cd drivers/spi/spi-pl022.c  Rabin Vincent            2015-11-23  1141  	}
f3d4bb3342630cd drivers/spi/spi-pl022.c  Rabin Vincent            2015-11-23  1142  
f3d4bb3342630cd drivers/spi/spi-pl022.c  Rabin Vincent            2015-11-23  1143  	pl022->dma_rx_channel = chan;
dc715452e914515 drivers/spi/spi-pl022.c  Arnd Bergmann            2013-01-28  1144  
f3d4bb3342630cd drivers/spi/spi-pl022.c  Rabin Vincent            2015-11-23  1145  	chan = dma_request_slave_channel_reason(dev, "tx");
f3d4bb3342630cd drivers/spi/spi-pl022.c  Rabin Vincent            2015-11-23  1146  	if (IS_ERR(chan)) {
f3d4bb3342630cd drivers/spi/spi-pl022.c  Rabin Vincent            2015-11-23  1147  		err = PTR_ERR(chan);
dc715452e914515 drivers/spi/spi-pl022.c  Arnd Bergmann            2013-01-28  1148  		goto err_no_txchan;
f3d4bb3342630cd drivers/spi/spi-pl022.c  Rabin Vincent            2015-11-23  1149  	}
f3d4bb3342630cd drivers/spi/spi-pl022.c  Rabin Vincent            2015-11-23  1150  
f3d4bb3342630cd drivers/spi/spi-pl022.c  Rabin Vincent            2015-11-23  1151  	pl022->dma_tx_channel = chan;
dc715452e914515 drivers/spi/spi-pl022.c  Arnd Bergmann            2013-01-28  1152  
dc715452e914515 drivers/spi/spi-pl022.c  Arnd Bergmann            2013-01-28  1153  	pl022->dummypage = kmalloc(PAGE_SIZE, GFP_KERNEL);
f3d4bb3342630cd drivers/spi/spi-pl022.c  Rabin Vincent            2015-11-23  1154  	if (!pl022->dummypage) {
f3d4bb3342630cd drivers/spi/spi-pl022.c  Rabin Vincent            2015-11-23  1155  		err = -ENOMEM;
dc715452e914515 drivers/spi/spi-pl022.c  Arnd Bergmann            2013-01-28  1156  		goto err_no_dummypage;
f3d4bb3342630cd drivers/spi/spi-pl022.c  Rabin Vincent            2015-11-23  1157  	}
dc715452e914515 drivers/spi/spi-pl022.c  Arnd Bergmann            2013-01-28  1158  
dc715452e914515 drivers/spi/spi-pl022.c  Arnd Bergmann            2013-01-28  1159  	return 0;
dc715452e914515 drivers/spi/spi-pl022.c  Arnd Bergmann            2013-01-28  1160  
dc715452e914515 drivers/spi/spi-pl022.c  Arnd Bergmann            2013-01-28  1161  err_no_dummypage:
dc715452e914515 drivers/spi/spi-pl022.c  Arnd Bergmann            2013-01-28  1162  	dma_release_channel(pl022->dma_tx_channel);
dc715452e914515 drivers/spi/spi-pl022.c  Arnd Bergmann            2013-01-28  1163  	pl022->dma_tx_channel = NULL;
dc715452e914515 drivers/spi/spi-pl022.c  Arnd Bergmann            2013-01-28  1164  err_no_txchan:
dc715452e914515 drivers/spi/spi-pl022.c  Arnd Bergmann            2013-01-28  1165  	dma_release_channel(pl022->dma_rx_channel);
dc715452e914515 drivers/spi/spi-pl022.c  Arnd Bergmann            2013-01-28  1166  	pl022->dma_rx_channel = NULL;
dc715452e914515 drivers/spi/spi-pl022.c  Arnd Bergmann            2013-01-28  1167  err_no_rxchan:
f3d4bb3342630cd drivers/spi/spi-pl022.c  Rabin Vincent            2015-11-23  1168  	return err;
dc715452e914515 drivers/spi/spi-pl022.c  Arnd Bergmann            2013-01-28  1169  }
dc715452e914515 drivers/spi/spi-pl022.c  Arnd Bergmann            2013-01-28  1170  		
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29  1171  static void terminate_dma(struct pl022 *pl022)
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29  1172  {
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29  1173  	struct dma_chan *rxchan = pl022->dma_rx_channel;
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29  1174  	struct dma_chan *txchan = pl022->dma_tx_channel;
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29  1175  
ecd442fd9e388a3 drivers/spi/amba-pl022.c Linus Walleij            2011-02-08  1176  	dmaengine_terminate_all(rxchan);
ecd442fd9e388a3 drivers/spi/amba-pl022.c Linus Walleij            2011-02-08  1177  	dmaengine_terminate_all(txchan);
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29  1178  	unmap_free_dma_scatter(pl022);
ffbbdd21329f3e1 drivers/spi/spi-pl022.c  Linus Walleij            2012-02-22  1179  	pl022->dma_running = false;
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29  1180  }
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29  1181  
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29  1182  static void pl022_dma_remove(struct pl022 *pl022)
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29  1183  {
ffbbdd21329f3e1 drivers/spi/spi-pl022.c  Linus Walleij            2012-02-22  1184  	if (pl022->dma_running)
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29  1185  		terminate_dma(pl022);
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29  1186  	if (pl022->dma_tx_channel)
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29  1187  		dma_release_channel(pl022->dma_tx_channel);
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29  1188  	if (pl022->dma_rx_channel)
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29  1189  		dma_release_channel(pl022->dma_rx_channel);
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29  1190  	kfree(pl022->dummypage);
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29  1191  }
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29  1192  
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29  1193  #else
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29  1194  static inline int configure_dma(struct pl022 *pl022)
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29  1195  {
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29  1196  	return -ENODEV;
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29  1197  }
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29  1198  
dc715452e914515 drivers/spi/spi-pl022.c  Arnd Bergmann            2013-01-28  1199  static inline int pl022_dma_autoprobe(struct pl022 *pl022)
dc715452e914515 drivers/spi/spi-pl022.c  Arnd Bergmann            2013-01-28  1200  {
dc715452e914515 drivers/spi/spi-pl022.c  Arnd Bergmann            2013-01-28  1201  	return 0;
dc715452e914515 drivers/spi/spi-pl022.c  Arnd Bergmann            2013-01-28  1202  }
dc715452e914515 drivers/spi/spi-pl022.c  Arnd Bergmann            2013-01-28  1203  
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29  1204  static inline int pl022_dma_probe(struct pl022 *pl022)
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29  1205  {
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29  1206  	return 0;
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29  1207  }
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29  1208  
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29  1209  static inline void pl022_dma_remove(struct pl022 *pl022)
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29  1210  {
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29  1211  }
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29  1212  #endif
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29  1213  
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1214  /**
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1215   * pl022_interrupt_handler - Interrupt handler for SSP controller
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1216   *
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1217   * This function handles interrupts generated for an interrupt based transfer.
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1218   * If a receive overrun (ROR) interrupt is there then we disable SSP, flag the
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1219   * current message's state as STATE_ERROR and schedule the tasklet
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1220   * pump_transfers which will do the postprocessing of the current message by
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1221   * calling giveback(). Otherwise it reads data from RX FIFO till there is no
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1222   * more data, and writes data in TX FIFO till it is not full. If we complete
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1223   * the transfer we move to the next transfer and schedule the tasklet.
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1224   */
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1225  static irqreturn_t pl022_interrupt_handler(int irq, void *dev_id)
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1226  {
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1227  	struct pl022 *pl022 = dev_id;
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1228  	struct spi_message *msg = pl022->cur_msg;
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1229  	u16 irq_status = 0;
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1230  
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1231  	if (unlikely(!msg)) {
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1232  		dev_err(&pl022->adev->dev,
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1233  			"bad message state in interrupt handler");
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1234  		/* Never fail */
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1235  		return IRQ_HANDLED;
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1236  	}
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1237  
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1238  	/* Read the Interrupt Status Register */
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1239  	irq_status = readw(SSP_MIS(pl022->virtbase));
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1240  
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1241  	if (unlikely(!irq_status))
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1242  		return IRQ_NONE;
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1243  
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29  1244  	/*
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29  1245  	 * This handles the FIFO interrupts, the timeout
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29  1246  	 * interrupts are flatly ignored, they cannot be
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29  1247  	 * trusted.
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29  1248  	 */
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1249  	if (unlikely(irq_status & SSP_MIS_MASK_RORMIS)) {
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1250  		/*
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1251  		 * Overrun interrupt - bail out since our Data has been
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1252  		 * corrupted
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1253  		 */
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29  1254  		dev_err(&pl022->adev->dev, "FIFO overrun\n");
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1255  		if (readw(SSP_SR(pl022->virtbase)) & SSP_SR_MASK_RFF)
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1256  			dev_err(&pl022->adev->dev,
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1257  				"RXFIFO is full\n");
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1258  
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1259  		/*
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1260  		 * Disable and clear interrupts, disable SSP,
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1261  		 * mark message with bad status so it can be
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1262  		 * retried.
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1263  		 */
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1264  		writew(DISABLE_ALL_INTERRUPTS,
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1265  		       SSP_IMSC(pl022->virtbase));
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1266  		writew(CLEAR_ALL_INTERRUPTS, SSP_ICR(pl022->virtbase));
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1267  		writew((readw(SSP_CR1(pl022->virtbase)) &
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1268  			(~SSP_CR1_MASK_SSE)), SSP_CR1(pl022->virtbase));
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1269  		msg->state = STATE_ERROR;
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1270  
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1271  		/* Schedule message queue handler */
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1272  		tasklet_schedule(&pl022->pump_transfers);
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1273  		return IRQ_HANDLED;
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1274  	}
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1275  
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1276  	readwriter(pl022);
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1277  
7183d1ebda477c4 drivers/spi/spi-pl022.c  Alexander Sverdlin       2015-02-27  1278  	if (pl022->tx == pl022->tx_end) {
172289df4004ccc drivers/spi/spi-pl022.c  Chris Blair              2011-06-04  1279  		/* Disable Transmit interrupt, enable receive interrupt */
172289df4004ccc drivers/spi/spi-pl022.c  Chris Blair              2011-06-04  1280  		writew((readw(SSP_IMSC(pl022->virtbase)) &
172289df4004ccc drivers/spi/spi-pl022.c  Chris Blair              2011-06-04  1281  		       ~SSP_IMSC_MASK_TXIM) | SSP_IMSC_MASK_RXIM,
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1282  		       SSP_IMSC(pl022->virtbase));
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1283  	}
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1284  
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1285  	/*
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1286  	 * Since all transactions must write as much as shall be read,
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1287  	 * we can conclude the entire transaction once RX is complete.
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1288  	 * At this point, all TX will always be finished.
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1289  	 */
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1290  	if (pl022->rx >= pl022->rx_end) {
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1291  		writew(DISABLE_ALL_INTERRUPTS,
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1292  		       SSP_IMSC(pl022->virtbase));
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1293  		writew(CLEAR_ALL_INTERRUPTS, SSP_ICR(pl022->virtbase));
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1294  		if (unlikely(pl022->rx > pl022->rx_end)) {
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1295  			dev_warn(&pl022->adev->dev, "read %u surplus "
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1296  				 "bytes (did you request an odd "
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1297  				 "number of bytes on a 16bit bus?)\n",
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1298  				 (u32) (pl022->rx - pl022->rx_end));
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1299  		}
25985edcedea639 drivers/spi/amba-pl022.c Lucas De Marchi          2011-03-30  1300  		/* Update total bytes transferred */
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1301  		msg->actual_length += pl022->cur_transfer->len;
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1302  		/* Move to next transfer */
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1303  		msg->state = next_transfer(pl022);
c0b07605f1a0285 drivers/spi/spi-pl022.c  Fredrik Ternerot         2018-11-13  1304  		if (msg->state != STATE_DONE && pl022->cur_transfer->cs_change)
c0b07605f1a0285 drivers/spi/spi-pl022.c  Fredrik Ternerot         2018-11-13  1305  			pl022_cs_control(pl022, SSP_CHIP_DESELECT);
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1306  		tasklet_schedule(&pl022->pump_transfers);
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1307  		return IRQ_HANDLED;
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1308  	}
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1309  
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1310  	return IRQ_HANDLED;
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1311  }
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1312  
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1313  /**
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1314   * This sets up the pointers to memory for the next message to
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1315   * send out on the SPI bus.
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1316   */
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1317  static int set_up_next_transfer(struct pl022 *pl022,
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1318  				struct spi_transfer *transfer)
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1319  {
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1320  	int residue;
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1321  
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1322  	/* Sanity check the message for this bus width */
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1323  	residue = pl022->cur_transfer->len % pl022->cur_chip->n_bytes;
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1324  	if (unlikely(residue != 0)) {
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1325  		dev_err(&pl022->adev->dev,
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1326  			"message of %u bytes to transmit but the current "
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1327  			"chip bus has a data width of %u bytes!\n",
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1328  			pl022->cur_transfer->len,
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1329  			pl022->cur_chip->n_bytes);
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1330  		dev_err(&pl022->adev->dev, "skipping this message\n");
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1331  		return -EIO;
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1332  	}
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1333  	pl022->tx = (void *)transfer->tx_buf;
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1334  	pl022->tx_end = pl022->tx + pl022->cur_transfer->len;
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1335  	pl022->rx = (void *)transfer->rx_buf;
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1336  	pl022->rx_end = pl022->rx + pl022->cur_transfer->len;
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1337  	pl022->write =
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1338  	    pl022->tx ? pl022->cur_chip->write : WRITING_NULL;
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1339  	pl022->read = pl022->rx ? pl022->cur_chip->read : READING_NULL;
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1340  	return 0;
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1341  }
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1342  
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1343  /**
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29  1344   * pump_transfers - Tasklet function which schedules next transfer
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29  1345   * when running in interrupt or DMA transfer mode.
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1346   * @data: SSP driver private data structure
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1347   *
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1348   */
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1349  static void pump_transfers(unsigned long data)
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1350  {
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1351  	struct pl022 *pl022 = (struct pl022 *) data;
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1352  	struct spi_message *message = NULL;
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1353  	struct spi_transfer *transfer = NULL;
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1354  	struct spi_transfer *previous = NULL;
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1355  
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1356  	/* Get current state information */
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1357  	message = pl022->cur_msg;
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1358  	transfer = pl022->cur_transfer;
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1359  
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1360  	/* Handle for abort */
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1361  	if (message->state == STATE_ERROR) {
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1362  		message->status = -EIO;
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1363  		giveback(pl022);
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1364  		return;
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1365  	}
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1366  
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1367  	/* Handle end of message */
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1368  	if (message->state == STATE_DONE) {
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1369  		message->status = 0;
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1370  		giveback(pl022);
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1371  		return;
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1372  	}
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1373  
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1374  	/* Delay if requested at end of transfer before CS change */
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1375  	if (message->state == STATE_RUNNING) {
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1376  		previous = list_entry(transfer->transfer_list.prev,
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1377  					struct spi_transfer,
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1378  					transfer_list);
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1379  		if (previous->delay_usecs)
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1380  			/*
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1381  			 * FIXME: This runs in interrupt context.
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1382  			 * Is this really smart?
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1383  			 */
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1384  			udelay(previous->delay_usecs);
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1385  
8b8d719161c3866 drivers/spi/spi-pl022.c  Virupax Sadashivpetimath 2011-11-10  1386  		/* Reselect chip select only if cs_change was requested */
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1387  		if (previous->cs_change)
f6f46de1063c882 drivers/spi/spi-pl022.c  Roland Stigge            2012-08-22  1388  			pl022_cs_control(pl022, SSP_CHIP_SELECT);
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1389  	} else {
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1390  		/* STATE_START */
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1391  		message->state = STATE_RUNNING;
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1392  	}
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1393  
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1394  	if (set_up_next_transfer(pl022, transfer)) {
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1395  		message->state = STATE_ERROR;
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1396  		message->status = -EIO;
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1397  		giveback(pl022);
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1398  		return;
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1399  	}
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1400  	/* Flush the FIFOs and let's go! */
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1401  	flush(pl022);
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1402  
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29  1403  	if (pl022->cur_chip->enable_dma) {
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29  1404  		if (configure_dma(pl022)) {
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29  1405  			dev_dbg(&pl022->adev->dev,
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29  1406  				"configuration of DMA failed, fall back to interrupt mode\n");
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1407  			goto err_config_dma;
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1408  		}
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1409  		return;
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1410  	}
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1411  
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1412  err_config_dma:
172289df4004ccc drivers/spi/spi-pl022.c  Chris Blair              2011-06-04  1413  	/* enable all interrupts except RX */
172289df4004ccc drivers/spi/spi-pl022.c  Chris Blair              2011-06-04  1414  	writew(ENABLE_ALL_INTERRUPTS & ~SSP_IMSC_MASK_RXIM, SSP_IMSC(pl022->virtbase));
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1415  }
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1416  
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29  1417  static void do_interrupt_dma_transfer(struct pl022 *pl022)
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1418  {
172289df4004ccc drivers/spi/spi-pl022.c  Chris Blair              2011-06-04  1419  	/*
172289df4004ccc drivers/spi/spi-pl022.c  Chris Blair              2011-06-04  1420  	 * Default is to enable all interrupts except RX -
172289df4004ccc drivers/spi/spi-pl022.c  Chris Blair              2011-06-04  1421  	 * this will be enabled once TX is complete
172289df4004ccc drivers/spi/spi-pl022.c  Chris Blair              2011-06-04  1422  	 */
d555ea05f9d8ebf drivers/spi/spi-pl022.c  Mark Brown               2014-08-01  1423  	u32 irqflags = (u32)(ENABLE_ALL_INTERRUPTS & ~SSP_IMSC_MASK_RXIM);
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1424  
8b8d719161c3866 drivers/spi/spi-pl022.c  Virupax Sadashivpetimath 2011-11-10  1425  	/* Enable target chip, if not already active */
8b8d719161c3866 drivers/spi/spi-pl022.c  Virupax Sadashivpetimath 2011-11-10  1426  	if (!pl022->next_msg_cs_active)
f6f46de1063c882 drivers/spi/spi-pl022.c  Roland Stigge            2012-08-22  1427  		pl022_cs_control(pl022, SSP_CHIP_SELECT);
8b8d719161c3866 drivers/spi/spi-pl022.c  Virupax Sadashivpetimath 2011-11-10  1428  
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1429  	if (set_up_next_transfer(pl022, pl022->cur_transfer)) {
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1430  		/* Error path */
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1431  		pl022->cur_msg->state = STATE_ERROR;
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1432  		pl022->cur_msg->status = -EIO;
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1433  		giveback(pl022);
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1434  		return;
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1435  	}
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29  1436  	/* If we're using DMA, set up DMA here */
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29  1437  	if (pl022->cur_chip->enable_dma) {
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29  1438  		/* Configure DMA transfer */
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29  1439  		if (configure_dma(pl022)) {
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29  1440  			dev_dbg(&pl022->adev->dev,
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29  1441  				"configuration of DMA failed, fall back to interrupt mode\n");
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29  1442  			goto err_config_dma;
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29  1443  		}
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29  1444  		/* Disable interrupts in DMA mode, IRQ from DMA controller */
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29  1445  		irqflags = DISABLE_ALL_INTERRUPTS;
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29  1446  	}
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29  1447  err_config_dma:
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1448  	/* Enable SSP, turn on interrupts */
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1449  	writew((readw(SSP_CR1(pl022->virtbase)) | SSP_CR1_MASK_SSE),
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1450  	       SSP_CR1(pl022->virtbase));
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29  1451  	writew(irqflags, SSP_IMSC(pl022->virtbase));
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1452  }
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1453  
7aef2b646b24247 drivers/spi/spi-pl022.c  Jiwei Sun                2019-01-18  1454  static void print_current_status(struct pl022 *pl022)
7aef2b646b24247 drivers/spi/spi-pl022.c  Jiwei Sun                2019-01-18  1455  {
7aef2b646b24247 drivers/spi/spi-pl022.c  Jiwei Sun                2019-01-18  1456  	u32 read_cr0;
7aef2b646b24247 drivers/spi/spi-pl022.c  Jiwei Sun                2019-01-18  1457  	u16 read_cr1, read_dmacr, read_sr;
7aef2b646b24247 drivers/spi/spi-pl022.c  Jiwei Sun                2019-01-18  1458  
7aef2b646b24247 drivers/spi/spi-pl022.c  Jiwei Sun                2019-01-18  1459  	if (pl022->vendor->extended_cr)
7aef2b646b24247 drivers/spi/spi-pl022.c  Jiwei Sun                2019-01-18  1460  		read_cr0 = readl(SSP_CR0(pl022->virtbase));
7aef2b646b24247 drivers/spi/spi-pl022.c  Jiwei Sun                2019-01-18  1461  	else
7aef2b646b24247 drivers/spi/spi-pl022.c  Jiwei Sun                2019-01-18  1462  		read_cr0 = readw(SSP_CR0(pl022->virtbase));
7aef2b646b24247 drivers/spi/spi-pl022.c  Jiwei Sun                2019-01-18  1463  	read_cr1 = readw(SSP_CR1(pl022->virtbase));
7aef2b646b24247 drivers/spi/spi-pl022.c  Jiwei Sun                2019-01-18  1464  	read_dmacr = readw(SSP_DMACR(pl022->virtbase));
7aef2b646b24247 drivers/spi/spi-pl022.c  Jiwei Sun                2019-01-18  1465  	read_sr = readw(SSP_SR(pl022->virtbase));
7aef2b646b24247 drivers/spi/spi-pl022.c  Jiwei Sun                2019-01-18  1466  
7aef2b646b24247 drivers/spi/spi-pl022.c  Jiwei Sun                2019-01-18  1467  	dev_warn(&pl022->adev->dev, "spi-pl022 CR0: %x\n", read_cr0);
7aef2b646b24247 drivers/spi/spi-pl022.c  Jiwei Sun                2019-01-18  1468  	dev_warn(&pl022->adev->dev, "spi-pl022 CR1: %x\n", read_cr1);
7aef2b646b24247 drivers/spi/spi-pl022.c  Jiwei Sun                2019-01-18  1469  	dev_warn(&pl022->adev->dev, "spi-pl022 DMACR: %x\n", read_dmacr);
7aef2b646b24247 drivers/spi/spi-pl022.c  Jiwei Sun                2019-01-18  1470  	dev_warn(&pl022->adev->dev, "spi-pl022 SR: %x\n", read_sr);
7aef2b646b24247 drivers/spi/spi-pl022.c  Jiwei Sun                2019-01-18  1471  	dev_warn(&pl022->adev->dev,
7aef2b646b24247 drivers/spi/spi-pl022.c  Jiwei Sun                2019-01-18  1472  			"spi-pl022 exp_fifo_level/fifodepth: %u/%d\n",
7aef2b646b24247 drivers/spi/spi-pl022.c  Jiwei Sun                2019-01-18  1473  			pl022->exp_fifo_level,
7aef2b646b24247 drivers/spi/spi-pl022.c  Jiwei Sun                2019-01-18  1474  			pl022->vendor->fifodepth);
7aef2b646b24247 drivers/spi/spi-pl022.c  Jiwei Sun                2019-01-18  1475  
7aef2b646b24247 drivers/spi/spi-pl022.c  Jiwei Sun                2019-01-18  1476  }
7aef2b646b24247 drivers/spi/spi-pl022.c  Jiwei Sun                2019-01-18  1477  
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29  1478  static void do_polling_transfer(struct pl022 *pl022)
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1479  {
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1480  	struct spi_message *message = NULL;
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1481  	struct spi_transfer *transfer = NULL;
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1482  	struct spi_transfer *previous = NULL;
a18c266f8e43004 drivers/spi/amba-pl022.c Magnus Templing          2011-05-19  1483  	unsigned long time, timeout;
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1484  
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1485  	message = pl022->cur_msg;
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1486  
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1487  	while (message->state != STATE_DONE) {
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1488  		/* Handle for abort */
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1489  		if (message->state == STATE_ERROR)
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1490  			break;
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1491  		transfer = pl022->cur_transfer;
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1492  
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1493  		/* Delay if requested at end of transfer */
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1494  		if (message->state == STATE_RUNNING) {
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1495  			previous =
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1496  			    list_entry(transfer->transfer_list.prev,
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1497  				       struct spi_transfer, transfer_list);
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1498  			if (previous->delay_usecs)
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1499  				udelay(previous->delay_usecs);
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1500  			if (previous->cs_change)
f6f46de1063c882 drivers/spi/spi-pl022.c  Roland Stigge            2012-08-22  1501  				pl022_cs_control(pl022, SSP_CHIP_SELECT);
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1502  		} else {
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1503  			/* STATE_START */
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1504  			message->state = STATE_RUNNING;
8b8d719161c3866 drivers/spi/spi-pl022.c  Virupax Sadashivpetimath 2011-11-10  1505  			if (!pl022->next_msg_cs_active)
f6f46de1063c882 drivers/spi/spi-pl022.c  Roland Stigge            2012-08-22  1506  				pl022_cs_control(pl022, SSP_CHIP_SELECT);
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1507  		}
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1508  
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1509  		/* Configuration Changing Per Transfer */
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1510  		if (set_up_next_transfer(pl022, transfer)) {
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1511  			/* Error path */
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1512  			message->state = STATE_ERROR;
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1513  			break;
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1514  		}
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1515  		/* Flush FIFOs and enable SSP */
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1516  		flush(pl022);
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1517  		writew((readw(SSP_CR1(pl022->virtbase)) | SSP_CR1_MASK_SSE),
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1518  		       SSP_CR1(pl022->virtbase));
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1519  
556f4aeb7d9dfac drivers/spi/amba-pl022.c Linus Walleij            2010-05-05  1520  		dev_dbg(&pl022->adev->dev, "polling transfer ongoing ...\n");
a18c266f8e43004 drivers/spi/amba-pl022.c Magnus Templing          2011-05-19  1521  
a18c266f8e43004 drivers/spi/amba-pl022.c Magnus Templing          2011-05-19  1522  		timeout = jiffies + msecs_to_jiffies(SPI_POLLING_TIMEOUT);
a18c266f8e43004 drivers/spi/amba-pl022.c Magnus Templing          2011-05-19  1523  		while (pl022->tx < pl022->tx_end || pl022->rx < pl022->rx_end) {
a18c266f8e43004 drivers/spi/amba-pl022.c Magnus Templing          2011-05-19  1524  			time = jiffies;
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1525  			readwriter(pl022);
a18c266f8e43004 drivers/spi/amba-pl022.c Magnus Templing          2011-05-19  1526  			if (time_after(time, timeout)) {
a18c266f8e43004 drivers/spi/amba-pl022.c Magnus Templing          2011-05-19  1527  				dev_warn(&pl022->adev->dev,
a18c266f8e43004 drivers/spi/amba-pl022.c Magnus Templing          2011-05-19  1528  				"%s: timeout!\n", __func__);
7aef2b646b24247 drivers/spi/spi-pl022.c  Jiwei Sun                2019-01-18  1529  				message->state = STATE_TIMEOUT;
7aef2b646b24247 drivers/spi/spi-pl022.c  Jiwei Sun                2019-01-18  1530  				print_current_status(pl022);
a18c266f8e43004 drivers/spi/amba-pl022.c Magnus Templing          2011-05-19  1531  				goto out;
a18c266f8e43004 drivers/spi/amba-pl022.c Magnus Templing          2011-05-19  1532  			}
521999bd4a8c47a drivers/spi/amba-pl022.c Linus Walleij            2011-05-19  1533  			cpu_relax();
a18c266f8e43004 drivers/spi/amba-pl022.c Magnus Templing          2011-05-19  1534  		}
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1535  
25985edcedea639 drivers/spi/amba-pl022.c Lucas De Marchi          2011-03-30  1536  		/* Update total byte transferred */
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1537  		message->actual_length += pl022->cur_transfer->len;
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1538  		/* Move to next transfer */
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1539  		message->state = next_transfer(pl022);
c0b07605f1a0285 drivers/spi/spi-pl022.c  Fredrik Ternerot         2018-11-13  1540  		if (message->state != STATE_DONE
c0b07605f1a0285 drivers/spi/spi-pl022.c  Fredrik Ternerot         2018-11-13  1541  		    && pl022->cur_transfer->cs_change)
c0b07605f1a0285 drivers/spi/spi-pl022.c  Fredrik Ternerot         2018-11-13  1542  			pl022_cs_control(pl022, SSP_CHIP_DESELECT);
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1543  	}
a18c266f8e43004 drivers/spi/amba-pl022.c Magnus Templing          2011-05-19  1544  out:
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1545  	/* Handle end of message */
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1546  	if (message->state == STATE_DONE)
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1547  		message->status = 0;
7aef2b646b24247 drivers/spi/spi-pl022.c  Jiwei Sun                2019-01-18  1548  	else if (message->state == STATE_TIMEOUT)
7aef2b646b24247 drivers/spi/spi-pl022.c  Jiwei Sun                2019-01-18  1549  		message->status = -EAGAIN;
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1550  	else
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1551  		message->status = -EIO;
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1552  
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1553  	giveback(pl022);
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1554  	return;
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1555  }
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1556  
ffbbdd21329f3e1 drivers/spi/spi-pl022.c  Linus Walleij            2012-02-22  1557  static int pl022_transfer_one_message(struct spi_master *master,
ffbbdd21329f3e1 drivers/spi/spi-pl022.c  Linus Walleij            2012-02-22  1558  				      struct spi_message *msg)
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1559  {
ffbbdd21329f3e1 drivers/spi/spi-pl022.c  Linus Walleij            2012-02-22  1560  	struct pl022 *pl022 = spi_master_get_devdata(master);
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1561  
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1562  	/* Initial message state */
ffbbdd21329f3e1 drivers/spi/spi-pl022.c  Linus Walleij            2012-02-22  1563  	pl022->cur_msg = msg;
ffbbdd21329f3e1 drivers/spi/spi-pl022.c  Linus Walleij            2012-02-22  1564  	msg->state = STATE_START;
ffbbdd21329f3e1 drivers/spi/spi-pl022.c  Linus Walleij            2012-02-22  1565  
ffbbdd21329f3e1 drivers/spi/spi-pl022.c  Linus Walleij            2012-02-22  1566  	pl022->cur_transfer = list_entry(msg->transfers.next,
f1e45f86ed93b9e drivers/spi/spi-pl022.c  Viresh Kumar             2011-08-10  1567  					 struct spi_transfer, transfer_list);
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1568  
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1569  	/* Setup the SPI using the per chip configuration */
ffbbdd21329f3e1 drivers/spi/spi-pl022.c  Linus Walleij            2012-02-22  1570  	pl022->cur_chip = spi_get_ctldata(msg->spi);
f6f46de1063c882 drivers/spi/spi-pl022.c  Roland Stigge            2012-08-22  1571  	pl022->cur_cs = pl022->chipselects[msg->spi->chip_select];
d4b6af2e0e29278 drivers/spi/spi-pl022.c  Chris Blair              2011-11-04  1572  
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1573  	restore_state(pl022);
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1574  	flush(pl022);
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1575  
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1576  	if (pl022->cur_chip->xfer_type == POLLING_TRANSFER)
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1577  		do_polling_transfer(pl022);
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1578  	else
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29  1579  		do_interrupt_dma_transfer(pl022);
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1580  
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1581  	return 0;
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1582  }
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1583  
ffbbdd21329f3e1 drivers/spi/spi-pl022.c  Linus Walleij            2012-02-22  1584  static int pl022_unprepare_transfer_hardware(struct spi_master *master)
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1585  {
ffbbdd21329f3e1 drivers/spi/spi-pl022.c  Linus Walleij            2012-02-22  1586  	struct pl022 *pl022 = spi_master_get_devdata(master);
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1587  
ffbbdd21329f3e1 drivers/spi/spi-pl022.c  Linus Walleij            2012-02-22  1588  	/* nothing more to do - disable spi/ssp and power off */
ffbbdd21329f3e1 drivers/spi/spi-pl022.c  Linus Walleij            2012-02-22  1589  	writew((readw(SSP_CR1(pl022->virtbase)) &
ffbbdd21329f3e1 drivers/spi/spi-pl022.c  Linus Walleij            2012-02-22  1590  		(~SSP_CR1_MASK_SSE)), SSP_CR1(pl022->virtbase));
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1591  
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1592  	return 0;
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1593  }
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1594  
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1595  static int verify_controller_parameters(struct pl022 *pl022,
f9d629c737cb668 drivers/spi/amba-pl022.c Linus Walleij            2010-10-01  1596  				struct pl022_config_chip const *chip_info)
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1597  {
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1598  	if ((chip_info->iface < SSP_INTERFACE_MOTOROLA_SPI)
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1599  	    || (chip_info->iface > SSP_INTERFACE_UNIDIRECTIONAL)) {
5a1c98be1de165c drivers/spi/amba-pl022.c Linus Walleij            2010-10-01  1600  		dev_err(&pl022->adev->dev,
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1601  			"interface is configured incorrectly\n");
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1602  		return -EINVAL;
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1603  	}
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1604  	if ((chip_info->iface == SSP_INTERFACE_UNIDIRECTIONAL) &&
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1605  	    (!pl022->vendor->unidir)) {
5a1c98be1de165c drivers/spi/amba-pl022.c Linus Walleij            2010-10-01  1606  		dev_err(&pl022->adev->dev,
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1607  			"unidirectional mode not supported in this "
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1608  			"hardware version\n");
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1609  		return -EINVAL;
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1610  	}
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1611  	if ((chip_info->hierarchy != SSP_MASTER)
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1612  	    && (chip_info->hierarchy != SSP_SLAVE)) {
5a1c98be1de165c drivers/spi/amba-pl022.c Linus Walleij            2010-10-01  1613  		dev_err(&pl022->adev->dev,
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1614  			"hierarchy is configured incorrectly\n");
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1615  		return -EINVAL;
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1616  	}
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1617  	if ((chip_info->com_mode != INTERRUPT_TRANSFER)
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1618  	    && (chip_info->com_mode != DMA_TRANSFER)
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1619  	    && (chip_info->com_mode != POLLING_TRANSFER)) {
5a1c98be1de165c drivers/spi/amba-pl022.c Linus Walleij            2010-10-01  1620  		dev_err(&pl022->adev->dev,
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1621  			"Communication mode is configured incorrectly\n");
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1622  		return -EINVAL;
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1623  	}
78b2b911bf70203 drivers/spi/spi-pl022.c  Linus Walleij            2011-06-16  1624  	switch (chip_info->rx_lev_trig) {
78b2b911bf70203 drivers/spi/spi-pl022.c  Linus Walleij            2011-06-16  1625  	case SSP_RX_1_OR_MORE_ELEM:
78b2b911bf70203 drivers/spi/spi-pl022.c  Linus Walleij            2011-06-16  1626  	case SSP_RX_4_OR_MORE_ELEM:
78b2b911bf70203 drivers/spi/spi-pl022.c  Linus Walleij            2011-06-16  1627  	case SSP_RX_8_OR_MORE_ELEM:
78b2b911bf70203 drivers/spi/spi-pl022.c  Linus Walleij            2011-06-16  1628  		/* These are always OK, all variants can handle this */
78b2b911bf70203 drivers/spi/spi-pl022.c  Linus Walleij            2011-06-16  1629  		break;
78b2b911bf70203 drivers/spi/spi-pl022.c  Linus Walleij            2011-06-16  1630  	case SSP_RX_16_OR_MORE_ELEM:
78b2b911bf70203 drivers/spi/spi-pl022.c  Linus Walleij            2011-06-16  1631  		if (pl022->vendor->fifodepth < 16) {
78b2b911bf70203 drivers/spi/spi-pl022.c  Linus Walleij            2011-06-16  1632  			dev_err(&pl022->adev->dev,
78b2b911bf70203 drivers/spi/spi-pl022.c  Linus Walleij            2011-06-16  1633  			"RX FIFO Trigger Level is configured incorrectly\n");
78b2b911bf70203 drivers/spi/spi-pl022.c  Linus Walleij            2011-06-16  1634  			return -EINVAL;
78b2b911bf70203 drivers/spi/spi-pl022.c  Linus Walleij            2011-06-16  1635  		}
78b2b911bf70203 drivers/spi/spi-pl022.c  Linus Walleij            2011-06-16  1636  		break;
78b2b911bf70203 drivers/spi/spi-pl022.c  Linus Walleij            2011-06-16  1637  	case SSP_RX_32_OR_MORE_ELEM:
78b2b911bf70203 drivers/spi/spi-pl022.c  Linus Walleij            2011-06-16  1638  		if (pl022->vendor->fifodepth < 32) {
5a1c98be1de165c drivers/spi/amba-pl022.c Linus Walleij            2010-10-01  1639  			dev_err(&pl022->adev->dev,
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1640  			"RX FIFO Trigger Level is configured incorrectly\n");
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1641  			return -EINVAL;
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1642  		}
78b2b911bf70203 drivers/spi/spi-pl022.c  Linus Walleij            2011-06-16  1643  		break;
78b2b911bf70203 drivers/spi/spi-pl022.c  Linus Walleij            2011-06-16  1644  	default:
78b2b911bf70203 drivers/spi/spi-pl022.c  Linus Walleij            2011-06-16  1645  		dev_err(&pl022->adev->dev,
78b2b911bf70203 drivers/spi/spi-pl022.c  Linus Walleij            2011-06-16  1646  			"RX FIFO Trigger Level is configured incorrectly\n");
78b2b911bf70203 drivers/spi/spi-pl022.c  Linus Walleij            2011-06-16  1647  		return -EINVAL;
78b2b911bf70203 drivers/spi/spi-pl022.c  Linus Walleij            2011-06-16  1648  	}
78b2b911bf70203 drivers/spi/spi-pl022.c  Linus Walleij            2011-06-16  1649  	switch (chip_info->tx_lev_trig) {
78b2b911bf70203 drivers/spi/spi-pl022.c  Linus Walleij            2011-06-16  1650  	case SSP_TX_1_OR_MORE_EMPTY_LOC:
78b2b911bf70203 drivers/spi/spi-pl022.c  Linus Walleij            2011-06-16  1651  	case SSP_TX_4_OR_MORE_EMPTY_LOC:
78b2b911bf70203 drivers/spi/spi-pl022.c  Linus Walleij            2011-06-16  1652  	case SSP_TX_8_OR_MORE_EMPTY_LOC:
78b2b911bf70203 drivers/spi/spi-pl022.c  Linus Walleij            2011-06-16  1653  		/* These are always OK, all variants can handle this */
78b2b911bf70203 drivers/spi/spi-pl022.c  Linus Walleij            2011-06-16  1654  		break;
78b2b911bf70203 drivers/spi/spi-pl022.c  Linus Walleij            2011-06-16  1655  	case SSP_TX_16_OR_MORE_EMPTY_LOC:
78b2b911bf70203 drivers/spi/spi-pl022.c  Linus Walleij            2011-06-16  1656  		if (pl022->vendor->fifodepth < 16) {
78b2b911bf70203 drivers/spi/spi-pl022.c  Linus Walleij            2011-06-16  1657  			dev_err(&pl022->adev->dev,
78b2b911bf70203 drivers/spi/spi-pl022.c  Linus Walleij            2011-06-16  1658  			"TX FIFO Trigger Level is configured incorrectly\n");
78b2b911bf70203 drivers/spi/spi-pl022.c  Linus Walleij            2011-06-16  1659  			return -EINVAL;
78b2b911bf70203 drivers/spi/spi-pl022.c  Linus Walleij            2011-06-16  1660  		}
78b2b911bf70203 drivers/spi/spi-pl022.c  Linus Walleij            2011-06-16  1661  		break;
78b2b911bf70203 drivers/spi/spi-pl022.c  Linus Walleij            2011-06-16  1662  	case SSP_TX_32_OR_MORE_EMPTY_LOC:
78b2b911bf70203 drivers/spi/spi-pl022.c  Linus Walleij            2011-06-16  1663  		if (pl022->vendor->fifodepth < 32) {
5a1c98be1de165c drivers/spi/amba-pl022.c Linus Walleij            2010-10-01  1664  			dev_err(&pl022->adev->dev,
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1665  			"TX FIFO Trigger Level is configured incorrectly\n");
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1666  			return -EINVAL;
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1667  		}
78b2b911bf70203 drivers/spi/spi-pl022.c  Linus Walleij            2011-06-16  1668  		break;
78b2b911bf70203 drivers/spi/spi-pl022.c  Linus Walleij            2011-06-16  1669  	default:
78b2b911bf70203 drivers/spi/spi-pl022.c  Linus Walleij            2011-06-16  1670  		dev_err(&pl022->adev->dev,
78b2b911bf70203 drivers/spi/spi-pl022.c  Linus Walleij            2011-06-16  1671  			"TX FIFO Trigger Level is configured incorrectly\n");
78b2b911bf70203 drivers/spi/spi-pl022.c  Linus Walleij            2011-06-16  1672  		return -EINVAL;
78b2b911bf70203 drivers/spi/spi-pl022.c  Linus Walleij            2011-06-16  1673  	}
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1674  	if (chip_info->iface == SSP_INTERFACE_NATIONAL_MICROWIRE) {
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1675  		if ((chip_info->ctrl_len < SSP_BITS_4)
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1676  		    || (chip_info->ctrl_len > SSP_BITS_32)) {
5a1c98be1de165c drivers/spi/amba-pl022.c Linus Walleij            2010-10-01  1677  			dev_err(&pl022->adev->dev,
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1678  				"CTRL LEN is configured incorrectly\n");
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1679  			return -EINVAL;
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1680  		}
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1681  		if ((chip_info->wait_state != SSP_MWIRE_WAIT_ZERO)
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1682  		    && (chip_info->wait_state != SSP_MWIRE_WAIT_ONE)) {
5a1c98be1de165c drivers/spi/amba-pl022.c Linus Walleij            2010-10-01  1683  			dev_err(&pl022->adev->dev,
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1684  				"Wait State is configured incorrectly\n");
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1685  			return -EINVAL;
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1686  		}
556f4aeb7d9dfac drivers/spi/amba-pl022.c Linus Walleij            2010-05-05  1687  		/* Half duplex is only available in the ST Micro version */
556f4aeb7d9dfac drivers/spi/amba-pl022.c Linus Walleij            2010-05-05  1688  		if (pl022->vendor->extended_cr) {
556f4aeb7d9dfac drivers/spi/amba-pl022.c Linus Walleij            2010-05-05  1689  			if ((chip_info->duplex !=
556f4aeb7d9dfac drivers/spi/amba-pl022.c Linus Walleij            2010-05-05  1690  			     SSP_MICROWIRE_CHANNEL_FULL_DUPLEX)
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1691  			    && (chip_info->duplex !=
4a4fd47155ac49b drivers/spi/amba-pl022.c Julia Lawall             2010-09-29  1692  				SSP_MICROWIRE_CHANNEL_HALF_DUPLEX)) {
5a1c98be1de165c drivers/spi/amba-pl022.c Linus Walleij            2010-10-01  1693  				dev_err(&pl022->adev->dev,
556f4aeb7d9dfac drivers/spi/amba-pl022.c Linus Walleij            2010-05-05  1694  					"Microwire duplex mode is configured incorrectly\n");
556f4aeb7d9dfac drivers/spi/amba-pl022.c Linus Walleij            2010-05-05  1695  				return -EINVAL;
4a4fd47155ac49b drivers/spi/amba-pl022.c Julia Lawall             2010-09-29  1696  			}
556f4aeb7d9dfac drivers/spi/amba-pl022.c Linus Walleij            2010-05-05  1697  		} else {
556f4aeb7d9dfac drivers/spi/amba-pl022.c Linus Walleij            2010-05-05  1698  			if (chip_info->duplex != SSP_MICROWIRE_CHANNEL_FULL_DUPLEX)
5a1c98be1de165c drivers/spi/amba-pl022.c Linus Walleij            2010-10-01  1699  				dev_err(&pl022->adev->dev,
556f4aeb7d9dfac drivers/spi/amba-pl022.c Linus Walleij            2010-05-05  1700  					"Microwire half duplex mode requested,"
556f4aeb7d9dfac drivers/spi/amba-pl022.c Linus Walleij            2010-05-05  1701  					" but this is only available in the"
556f4aeb7d9dfac drivers/spi/amba-pl022.c Linus Walleij            2010-05-05  1702  					" ST version of PL022\n");
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1703  			return -EINVAL;
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1704  		}
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1705  	}
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1706  	return 0;
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1707  }
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1708  
0379b2a33a8a03d drivers/spi/spi-pl022.c  Viresh Kumar             2011-08-10  1709  static inline u32 spi_rate(u32 rate, u16 cpsdvsr, u16 scr)
0379b2a33a8a03d drivers/spi/spi-pl022.c  Viresh Kumar             2011-08-10  1710  {
0379b2a33a8a03d drivers/spi/spi-pl022.c  Viresh Kumar             2011-08-10  1711  	return rate / (cpsdvsr * (1 + scr));
0379b2a33a8a03d drivers/spi/spi-pl022.c  Viresh Kumar             2011-08-10  1712  }
0379b2a33a8a03d drivers/spi/spi-pl022.c  Viresh Kumar             2011-08-10  1713  
0379b2a33a8a03d drivers/spi/spi-pl022.c  Viresh Kumar             2011-08-10  1714  static int calculate_effective_freq(struct pl022 *pl022, int freq, struct
0379b2a33a8a03d drivers/spi/spi-pl022.c  Viresh Kumar             2011-08-10  1715  				    ssp_clock_params * clk_freq)
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1716  {
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1717  	/* Lets calculate the frequency parameters */
0379b2a33a8a03d drivers/spi/spi-pl022.c  Viresh Kumar             2011-08-10  1718  	u16 cpsdvsr = CPSDVR_MIN, scr = SCR_MIN;
0379b2a33a8a03d drivers/spi/spi-pl022.c  Viresh Kumar             2011-08-10  1719  	u32 rate, max_tclk, min_tclk, best_freq = 0, best_cpsdvsr = 0,
0379b2a33a8a03d drivers/spi/spi-pl022.c  Viresh Kumar             2011-08-10  1720  		best_scr = 0, tmp, found = 0;
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1721  
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1722  	rate = clk_get_rate(pl022->clk);
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1723  	/* cpsdvscr = 2 & scr 0 */
0379b2a33a8a03d drivers/spi/spi-pl022.c  Viresh Kumar             2011-08-10  1724  	max_tclk = spi_rate(rate, CPSDVR_MIN, SCR_MIN);
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1725  	/* cpsdvsr = 254 & scr = 255 */
0379b2a33a8a03d drivers/spi/spi-pl022.c  Viresh Kumar             2011-08-10  1726  	min_tclk = spi_rate(rate, CPSDVR_MAX, SCR_MAX);
0379b2a33a8a03d drivers/spi/spi-pl022.c  Viresh Kumar             2011-08-10  1727  
ea505bc99f77f3f drivers/spi/spi-pl022.c  Viresh Kumar             2012-04-19  1728  	if (freq > max_tclk)
ea505bc99f77f3f drivers/spi/spi-pl022.c  Viresh Kumar             2012-04-19  1729  		dev_warn(&pl022->adev->dev,
ea505bc99f77f3f drivers/spi/spi-pl022.c  Viresh Kumar             2012-04-19  1730  			"Max speed that can be programmed is %d Hz, you requested %d\n",
ea505bc99f77f3f drivers/spi/spi-pl022.c  Viresh Kumar             2012-04-19  1731  			max_tclk, freq);
ea505bc99f77f3f drivers/spi/spi-pl022.c  Viresh Kumar             2012-04-19  1732  
ea505bc99f77f3f drivers/spi/spi-pl022.c  Viresh Kumar             2012-04-19  1733  	if (freq < min_tclk) {
0379b2a33a8a03d drivers/spi/spi-pl022.c  Viresh Kumar             2011-08-10  1734  		dev_err(&pl022->adev->dev,
ea505bc99f77f3f drivers/spi/spi-pl022.c  Viresh Kumar             2012-04-19  1735  			"Requested frequency: %d Hz is less than minimum possible %d Hz\n",
ea505bc99f77f3f drivers/spi/spi-pl022.c  Viresh Kumar             2012-04-19  1736  			freq, min_tclk);
0379b2a33a8a03d drivers/spi/spi-pl022.c  Viresh Kumar             2011-08-10  1737  		return -EINVAL;
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1738  	}
0379b2a33a8a03d drivers/spi/spi-pl022.c  Viresh Kumar             2011-08-10  1739  
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1740  	/*
0379b2a33a8a03d drivers/spi/spi-pl022.c  Viresh Kumar             2011-08-10  1741  	 * best_freq will give closest possible available rate (<= requested
0379b2a33a8a03d drivers/spi/spi-pl022.c  Viresh Kumar             2011-08-10  1742  	 * freq) for all values of scr & cpsdvsr.
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1743  	 */
0379b2a33a8a03d drivers/spi/spi-pl022.c  Viresh Kumar             2011-08-10  1744  	while ((cpsdvsr <= CPSDVR_MAX) && !found) {
0379b2a33a8a03d drivers/spi/spi-pl022.c  Viresh Kumar             2011-08-10  1745  		while (scr <= SCR_MAX) {
0379b2a33a8a03d drivers/spi/spi-pl022.c  Viresh Kumar             2011-08-10  1746  			tmp = spi_rate(rate, cpsdvsr, scr);
0379b2a33a8a03d drivers/spi/spi-pl022.c  Viresh Kumar             2011-08-10  1747  
5eb806a3a68920a drivers/spi/spi-pl022.c  Viresh Kumar             2012-04-19  1748  			if (tmp > freq) {
5eb806a3a68920a drivers/spi/spi-pl022.c  Viresh Kumar             2012-04-19  1749  				/* we need lower freq */
0379b2a33a8a03d drivers/spi/spi-pl022.c  Viresh Kumar             2011-08-10  1750  				scr++;
5eb806a3a68920a drivers/spi/spi-pl022.c  Viresh Kumar             2012-04-19  1751  				continue;
5eb806a3a68920a drivers/spi/spi-pl022.c  Viresh Kumar             2012-04-19  1752  			}
5eb806a3a68920a drivers/spi/spi-pl022.c  Viresh Kumar             2012-04-19  1753  
0379b2a33a8a03d drivers/spi/spi-pl022.c  Viresh Kumar             2011-08-10  1754  			/*
5eb806a3a68920a drivers/spi/spi-pl022.c  Viresh Kumar             2012-04-19  1755  			 * If found exact value, mark found and break.
5eb806a3a68920a drivers/spi/spi-pl022.c  Viresh Kumar             2012-04-19  1756  			 * If found more closer value, update and break.
0379b2a33a8a03d drivers/spi/spi-pl022.c  Viresh Kumar             2011-08-10  1757  			 */
5eb806a3a68920a drivers/spi/spi-pl022.c  Viresh Kumar             2012-04-19  1758  			if (tmp > best_freq) {
0379b2a33a8a03d drivers/spi/spi-pl022.c  Viresh Kumar             2011-08-10  1759  				best_freq = tmp;
0379b2a33a8a03d drivers/spi/spi-pl022.c  Viresh Kumar             2011-08-10  1760  				best_cpsdvsr = cpsdvsr;
0379b2a33a8a03d drivers/spi/spi-pl022.c  Viresh Kumar             2011-08-10  1761  				best_scr = scr;
0379b2a33a8a03d drivers/spi/spi-pl022.c  Viresh Kumar             2011-08-10  1762  
0379b2a33a8a03d drivers/spi/spi-pl022.c  Viresh Kumar             2011-08-10  1763  				if (tmp == freq)
5eb806a3a68920a drivers/spi/spi-pl022.c  Viresh Kumar             2012-04-19  1764  					found = 1;
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1765  			}
5eb806a3a68920a drivers/spi/spi-pl022.c  Viresh Kumar             2012-04-19  1766  			/*
5eb806a3a68920a drivers/spi/spi-pl022.c  Viresh Kumar             2012-04-19  1767  			 * increased scr will give lower rates, which are not
5eb806a3a68920a drivers/spi/spi-pl022.c  Viresh Kumar             2012-04-19  1768  			 * required
5eb806a3a68920a drivers/spi/spi-pl022.c  Viresh Kumar             2012-04-19  1769  			 */
5eb806a3a68920a drivers/spi/spi-pl022.c  Viresh Kumar             2012-04-19  1770  			break;
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1771  		}
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1772  		cpsdvsr += 2;
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1773  		scr = SCR_MIN;
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1774  	}
0379b2a33a8a03d drivers/spi/spi-pl022.c  Viresh Kumar             2011-08-10  1775  
5eb806a3a68920a drivers/spi/spi-pl022.c  Viresh Kumar             2012-04-19  1776  	WARN(!best_freq, "pl022: Matching cpsdvsr and scr not found for %d Hz rate \n",
5eb806a3a68920a drivers/spi/spi-pl022.c  Viresh Kumar             2012-04-19  1777  			freq);
5eb806a3a68920a drivers/spi/spi-pl022.c  Viresh Kumar             2012-04-19  1778  
0379b2a33a8a03d drivers/spi/spi-pl022.c  Viresh Kumar             2011-08-10  1779  	clk_freq->cpsdvsr = (u8) (best_cpsdvsr & 0xFF);
0379b2a33a8a03d drivers/spi/spi-pl022.c  Viresh Kumar             2011-08-10  1780  	clk_freq->scr = (u8) (best_scr & 0xFF);
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1781  	dev_dbg(&pl022->adev->dev,
0379b2a33a8a03d drivers/spi/spi-pl022.c  Viresh Kumar             2011-08-10  1782  		"SSP Target Frequency is: %u, Effective Frequency is %u\n",
0379b2a33a8a03d drivers/spi/spi-pl022.c  Viresh Kumar             2011-08-10  1783  		freq, best_freq);
0379b2a33a8a03d drivers/spi/spi-pl022.c  Viresh Kumar             2011-08-10  1784  	dev_dbg(&pl022->adev->dev, "SSP cpsdvsr = %d, scr = %d\n",
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1785  		clk_freq->cpsdvsr, clk_freq->scr);
0379b2a33a8a03d drivers/spi/spi-pl022.c  Viresh Kumar             2011-08-10  1786  
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1787  	return 0;
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1788  }
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1789  
f9d629c737cb668 drivers/spi/amba-pl022.c Linus Walleij            2010-10-01  1790  /*
f9d629c737cb668 drivers/spi/amba-pl022.c Linus Walleij            2010-10-01  1791   * A piece of default chip info unless the platform
f9d629c737cb668 drivers/spi/amba-pl022.c Linus Walleij            2010-10-01  1792   * supplies it.
f9d629c737cb668 drivers/spi/amba-pl022.c Linus Walleij            2010-10-01  1793   */
f9d629c737cb668 drivers/spi/amba-pl022.c Linus Walleij            2010-10-01  1794  static const struct pl022_config_chip pl022_default_chip_info = {
f9d629c737cb668 drivers/spi/amba-pl022.c Linus Walleij            2010-10-01  1795  	.com_mode = POLLING_TRANSFER,
f9d629c737cb668 drivers/spi/amba-pl022.c Linus Walleij            2010-10-01  1796  	.iface = SSP_INTERFACE_MOTOROLA_SPI,
f9d629c737cb668 drivers/spi/amba-pl022.c Linus Walleij            2010-10-01  1797  	.hierarchy = SSP_SLAVE,
f9d629c737cb668 drivers/spi/amba-pl022.c Linus Walleij            2010-10-01  1798  	.slave_tx_disable = DO_NOT_DRIVE_TX,
f9d629c737cb668 drivers/spi/amba-pl022.c Linus Walleij            2010-10-01  1799  	.rx_lev_trig = SSP_RX_1_OR_MORE_ELEM,
f9d629c737cb668 drivers/spi/amba-pl022.c Linus Walleij            2010-10-01  1800  	.tx_lev_trig = SSP_TX_1_OR_MORE_EMPTY_LOC,
f9d629c737cb668 drivers/spi/amba-pl022.c Linus Walleij            2010-10-01  1801  	.ctrl_len = SSP_BITS_8,
f9d629c737cb668 drivers/spi/amba-pl022.c Linus Walleij            2010-10-01  1802  	.wait_state = SSP_MWIRE_WAIT_ZERO,
f9d629c737cb668 drivers/spi/amba-pl022.c Linus Walleij            2010-10-01  1803  	.duplex = SSP_MICROWIRE_CHANNEL_FULL_DUPLEX,
f9d629c737cb668 drivers/spi/amba-pl022.c Linus Walleij            2010-10-01  1804  };
f9d629c737cb668 drivers/spi/amba-pl022.c Linus Walleij            2010-10-01  1805  
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1806  /**
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1807   * pl022_setup - setup function registered to SPI master framework
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1808   * @spi: spi device which is requesting setup
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1809   *
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1810   * This function is registered to the SPI framework for this SPI master
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1811   * controller. If it is the first time when setup is called by this device,
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1812   * this function will initialize the runtime state for this chip and save
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1813   * the same in the device structure. Else it will update the runtime info
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1814   * with the updated chip info. Nothing is really being written to the
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1815   * controller hardware here, that is not done until the actual transfer
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1816   * commence.
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1817   */
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1818  static int pl022_setup(struct spi_device *spi)
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1819  {
f9d629c737cb668 drivers/spi/amba-pl022.c Linus Walleij            2010-10-01  1820  	struct pl022_config_chip const *chip_info;
6d3952a7dfa8091 drivers/spi/spi-pl022.c  Roland Stigge            2012-08-22  1821  	struct pl022_config_chip chip_info_dt;
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1822  	struct chip_data *chip;
c4a4784308f5cb8 drivers/spi/spi-pl022.c  Jonas Aaberg             2011-02-28  1823  	struct ssp_clock_params clk_freq = { .cpsdvsr = 0, .scr = 0};
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1824  	int status = 0;
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1825  	struct pl022 *pl022 = spi_master_get_devdata(spi->master);
bde435a9ca376d0 drivers/spi/amba-pl022.c Kevin Wells              2010-09-16  1826  	unsigned int bits = spi->bits_per_word;
bde435a9ca376d0 drivers/spi/amba-pl022.c Kevin Wells              2010-09-16  1827  	u32 tmp;
6d3952a7dfa8091 drivers/spi/spi-pl022.c  Roland Stigge            2012-08-22  1828  	struct device_node *np = spi->dev.of_node;
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1829  
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1830  	if (!spi->max_speed_hz)
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1831  		return -EINVAL;
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1832  
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1833  	/* Get controller_state if one is supplied */
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1834  	chip = spi_get_ctldata(spi);
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1835  
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1836  	if (chip == NULL) {
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1837  		chip = kzalloc(sizeof(struct chip_data), GFP_KERNEL);
77538f4a98dc542 drivers/spi/spi-pl022.c  Jingoo Han               2014-04-29  1838  		if (!chip)
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1839  			return -ENOMEM;
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1840  		dev_dbg(&spi->dev,
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1841  			"allocated memory for controller's runtime state\n");
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1842  	}
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1843  
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1844  	/* Get controller data if one is supplied */
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1845  	chip_info = spi->controller_data;
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1846  
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1847  	if (chip_info == NULL) {
6d3952a7dfa8091 drivers/spi/spi-pl022.c  Roland Stigge            2012-08-22  1848  		if (np) {
6d3952a7dfa8091 drivers/spi/spi-pl022.c  Roland Stigge            2012-08-22  1849  			chip_info_dt = pl022_default_chip_info;
6d3952a7dfa8091 drivers/spi/spi-pl022.c  Roland Stigge            2012-08-22  1850  
6d3952a7dfa8091 drivers/spi/spi-pl022.c  Roland Stigge            2012-08-22  1851  			chip_info_dt.hierarchy = SSP_MASTER;
6d3952a7dfa8091 drivers/spi/spi-pl022.c  Roland Stigge            2012-08-22  1852  			of_property_read_u32(np, "pl022,interface",
6d3952a7dfa8091 drivers/spi/spi-pl022.c  Roland Stigge            2012-08-22  1853  				&chip_info_dt.iface);
6d3952a7dfa8091 drivers/spi/spi-pl022.c  Roland Stigge            2012-08-22  1854  			of_property_read_u32(np, "pl022,com-mode",
6d3952a7dfa8091 drivers/spi/spi-pl022.c  Roland Stigge            2012-08-22  1855  				&chip_info_dt.com_mode);
6d3952a7dfa8091 drivers/spi/spi-pl022.c  Roland Stigge            2012-08-22  1856  			of_property_read_u32(np, "pl022,rx-level-trig",
6d3952a7dfa8091 drivers/spi/spi-pl022.c  Roland Stigge            2012-08-22  1857  				&chip_info_dt.rx_lev_trig);
6d3952a7dfa8091 drivers/spi/spi-pl022.c  Roland Stigge            2012-08-22  1858  			of_property_read_u32(np, "pl022,tx-level-trig",
6d3952a7dfa8091 drivers/spi/spi-pl022.c  Roland Stigge            2012-08-22  1859  				&chip_info_dt.tx_lev_trig);
6d3952a7dfa8091 drivers/spi/spi-pl022.c  Roland Stigge            2012-08-22  1860  			of_property_read_u32(np, "pl022,ctrl-len",
6d3952a7dfa8091 drivers/spi/spi-pl022.c  Roland Stigge            2012-08-22  1861  				&chip_info_dt.ctrl_len);
6d3952a7dfa8091 drivers/spi/spi-pl022.c  Roland Stigge            2012-08-22  1862  			of_property_read_u32(np, "pl022,wait-state",
6d3952a7dfa8091 drivers/spi/spi-pl022.c  Roland Stigge            2012-08-22  1863  				&chip_info_dt.wait_state);
6d3952a7dfa8091 drivers/spi/spi-pl022.c  Roland Stigge            2012-08-22  1864  			of_property_read_u32(np, "pl022,duplex",
6d3952a7dfa8091 drivers/spi/spi-pl022.c  Roland Stigge            2012-08-22  1865  				&chip_info_dt.duplex);
6d3952a7dfa8091 drivers/spi/spi-pl022.c  Roland Stigge            2012-08-22  1866  
6d3952a7dfa8091 drivers/spi/spi-pl022.c  Roland Stigge            2012-08-22  1867  			chip_info = &chip_info_dt;
6d3952a7dfa8091 drivers/spi/spi-pl022.c  Roland Stigge            2012-08-22  1868  		} else {
f9d629c737cb668 drivers/spi/amba-pl022.c Linus Walleij            2010-10-01  1869  			chip_info = &pl022_default_chip_info;
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1870  			/* spi_board_info.controller_data not is supplied */
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1871  			dev_dbg(&spi->dev,
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1872  				"using default controller_data settings\n");
6d3952a7dfa8091 drivers/spi/spi-pl022.c  Roland Stigge            2012-08-22  1873  		}
f9d629c737cb668 drivers/spi/amba-pl022.c Linus Walleij            2010-10-01  1874  	} else
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1875  		dev_dbg(&spi->dev,
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1876  			"using user supplied controller_data settings\n");
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1877  
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1878  	/*
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1879  	 * We can override with custom divisors, else we use the board
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1880  	 * frequency setting
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1881  	 */
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1882  	if ((0 == chip_info->clk_freq.cpsdvsr)
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1883  	    && (0 == chip_info->clk_freq.scr)) {
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1884  		status = calculate_effective_freq(pl022,
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1885  						  spi->max_speed_hz,
f9d629c737cb668 drivers/spi/amba-pl022.c Linus Walleij            2010-10-01  1886  						  &clk_freq);
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1887  		if (status < 0)
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1888  			goto err_config_params;
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1889  	} else {
f9d629c737cb668 drivers/spi/amba-pl022.c Linus Walleij            2010-10-01  1890  		memcpy(&clk_freq, &chip_info->clk_freq, sizeof(clk_freq));
f9d629c737cb668 drivers/spi/amba-pl022.c Linus Walleij            2010-10-01  1891  		if ((clk_freq.cpsdvsr % 2) != 0)
f9d629c737cb668 drivers/spi/amba-pl022.c Linus Walleij            2010-10-01  1892  			clk_freq.cpsdvsr =
f9d629c737cb668 drivers/spi/amba-pl022.c Linus Walleij            2010-10-01  1893  				clk_freq.cpsdvsr - 1;
f9d629c737cb668 drivers/spi/amba-pl022.c Linus Walleij            2010-10-01  1894  	}
f9d629c737cb668 drivers/spi/amba-pl022.c Linus Walleij            2010-10-01  1895  	if ((clk_freq.cpsdvsr < CPSDVR_MIN)
f9d629c737cb668 drivers/spi/amba-pl022.c Linus Walleij            2010-10-01  1896  	    || (clk_freq.cpsdvsr > CPSDVR_MAX)) {
e3f88ae99609205 drivers/spi/amba-pl022.c Virupax Sadashivpetimath 2011-06-13  1897  		status = -EINVAL;
f9d629c737cb668 drivers/spi/amba-pl022.c Linus Walleij            2010-10-01  1898  		dev_err(&spi->dev,
f9d629c737cb668 drivers/spi/amba-pl022.c Linus Walleij            2010-10-01  1899  			"cpsdvsr is configured incorrectly\n");
f9d629c737cb668 drivers/spi/amba-pl022.c Linus Walleij            2010-10-01  1900  		goto err_config_params;
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1901  	}
f9d629c737cb668 drivers/spi/amba-pl022.c Linus Walleij            2010-10-01  1902  
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1903  	status = verify_controller_parameters(pl022, chip_info);
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1904  	if (status) {
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1905  		dev_err(&spi->dev, "controller data is incorrect");
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1906  		goto err_config_params;
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1907  	}
f9d629c737cb668 drivers/spi/amba-pl022.c Linus Walleij            2010-10-01  1908  
083be3f05371b8f drivers/spi/spi-pl022.c  Linus Walleij            2011-06-16  1909  	pl022->rx_lev_trig = chip_info->rx_lev_trig;
083be3f05371b8f drivers/spi/spi-pl022.c  Linus Walleij            2011-06-16  1910  	pl022->tx_lev_trig = chip_info->tx_lev_trig;
083be3f05371b8f drivers/spi/spi-pl022.c  Linus Walleij            2011-06-16  1911  
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1912  	/* Now set controller state based on controller data */
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1913  	chip->xfer_type = chip_info->com_mode;
f6f46de1063c882 drivers/spi/spi-pl022.c  Roland Stigge            2012-08-22  1914  	if (!gpio_is_valid(pl022->chipselects[spi->chip_select]))
f9d629c737cb668 drivers/spi/amba-pl022.c Linus Walleij            2010-10-01  1915  		dev_warn(&spi->dev,
f6f46de1063c882 drivers/spi/spi-pl022.c  Roland Stigge            2012-08-22  1916  			 "invalid chip select\n");
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1917  
eb798c641a34ae9 drivers/spi/spi-pl022.c  Vinit Shenoy             2012-04-17  1918  	/* Check bits per word with vendor specific range */
eb798c641a34ae9 drivers/spi/spi-pl022.c  Vinit Shenoy             2012-04-17  1919  	if ((bits <= 3) || (bits > pl022->vendor->max_bpw)) {
bde435a9ca376d0 drivers/spi/amba-pl022.c Kevin Wells              2010-09-16  1920  		status = -ENOTSUPP;
eb798c641a34ae9 drivers/spi/spi-pl022.c  Vinit Shenoy             2012-04-17  1921  		dev_err(&spi->dev, "illegal data size for this controller!\n");
eb798c641a34ae9 drivers/spi/spi-pl022.c  Vinit Shenoy             2012-04-17  1922  		dev_err(&spi->dev, "This controller can only handle 4 <= n <= %d bit words\n",
eb798c641a34ae9 drivers/spi/spi-pl022.c  Vinit Shenoy             2012-04-17  1923  				pl022->vendor->max_bpw);
bde435a9ca376d0 drivers/spi/amba-pl022.c Kevin Wells              2010-09-16  1924  		goto err_config_params;
bde435a9ca376d0 drivers/spi/amba-pl022.c Kevin Wells              2010-09-16  1925  	} else if (bits <= 8) {
bde435a9ca376d0 drivers/spi/amba-pl022.c Kevin Wells              2010-09-16  1926  		dev_dbg(&spi->dev, "4 <= n <=8 bits per word\n");
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1927  		chip->n_bytes = 1;
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1928  		chip->read = READING_U8;
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1929  		chip->write = WRITING_U8;
bde435a9ca376d0 drivers/spi/amba-pl022.c Kevin Wells              2010-09-16  1930  	} else if (bits <= 16) {
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1931  		dev_dbg(&spi->dev, "9 <= n <= 16 bits per word\n");
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1932  		chip->n_bytes = 2;
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1933  		chip->read = READING_U16;
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1934  		chip->write = WRITING_U16;
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1935  	} else {
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1936  		dev_dbg(&spi->dev, "17 <= n <= 32 bits per word\n");
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1937  		chip->n_bytes = 4;
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1938  		chip->read = READING_U32;
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1939  		chip->write = WRITING_U32;
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1940  	}
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1941  
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1942  	/* Now Initialize all register settings required for this chip */
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1943  	chip->cr0 = 0;
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1944  	chip->cr1 = 0;
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1945  	chip->dmacr = 0;
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1946  	chip->cpsr = 0;
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1947  	if ((chip_info->com_mode == DMA_TRANSFER)
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1948  	    && ((pl022->master_info)->enable_dma)) {
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29  1949  		chip->enable_dma = true;
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1950  		dev_dbg(&spi->dev, "DMA mode set in controller state\n");
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1951  		SSP_WRITE_BITS(chip->dmacr, SSP_DMA_ENABLED,
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1952  			       SSP_DMACR_MASK_RXDMAE, 0);
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1953  		SSP_WRITE_BITS(chip->dmacr, SSP_DMA_ENABLED,
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1954  			       SSP_DMACR_MASK_TXDMAE, 1);
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1955  	} else {
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29  1956  		chip->enable_dma = false;
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1957  		dev_dbg(&spi->dev, "DMA mode NOT set in controller state\n");
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1958  		SSP_WRITE_BITS(chip->dmacr, SSP_DMA_DISABLED,
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1959  			       SSP_DMACR_MASK_RXDMAE, 0);
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1960  		SSP_WRITE_BITS(chip->dmacr, SSP_DMA_DISABLED,
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1961  			       SSP_DMACR_MASK_TXDMAE, 1);
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1962  	}
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1963  
f9d629c737cb668 drivers/spi/amba-pl022.c Linus Walleij            2010-10-01  1964  	chip->cpsr = clk_freq.cpsdvsr;
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1965  
556f4aeb7d9dfac drivers/spi/amba-pl022.c Linus Walleij            2010-05-05  1966  	/* Special setup for the ST micro extended control registers */
556f4aeb7d9dfac drivers/spi/amba-pl022.c Linus Walleij            2010-05-05  1967  	if (pl022->vendor->extended_cr) {
bde435a9ca376d0 drivers/spi/amba-pl022.c Kevin Wells              2010-09-16  1968  		u32 etx;
bde435a9ca376d0 drivers/spi/amba-pl022.c Kevin Wells              2010-09-16  1969  
781c7b129b1beb8 drivers/spi/amba-pl022.c Linus Walleij            2010-05-07  1970  		if (pl022->vendor->pl023) {
781c7b129b1beb8 drivers/spi/amba-pl022.c Linus Walleij            2010-05-07  1971  			/* These bits are only in the PL023 */
781c7b129b1beb8 drivers/spi/amba-pl022.c Linus Walleij            2010-05-07  1972  			SSP_WRITE_BITS(chip->cr1, chip_info->clkdelay,
781c7b129b1beb8 drivers/spi/amba-pl022.c Linus Walleij            2010-05-07  1973  				       SSP_CR1_MASK_FBCLKDEL_ST, 13);
781c7b129b1beb8 drivers/spi/amba-pl022.c Linus Walleij            2010-05-07  1974  		} else {
781c7b129b1beb8 drivers/spi/amba-pl022.c Linus Walleij            2010-05-07  1975  			/* These bits are in the PL022 but not PL023 */
556f4aeb7d9dfac drivers/spi/amba-pl022.c Linus Walleij            2010-05-05  1976  			SSP_WRITE_BITS(chip->cr0, chip_info->duplex,
556f4aeb7d9dfac drivers/spi/amba-pl022.c Linus Walleij            2010-05-05  1977  				       SSP_CR0_MASK_HALFDUP_ST, 5);
556f4aeb7d9dfac drivers/spi/amba-pl022.c Linus Walleij            2010-05-05  1978  			SSP_WRITE_BITS(chip->cr0, chip_info->ctrl_len,
556f4aeb7d9dfac drivers/spi/amba-pl022.c Linus Walleij            2010-05-05  1979  				       SSP_CR0_MASK_CSS_ST, 16);
556f4aeb7d9dfac drivers/spi/amba-pl022.c Linus Walleij            2010-05-05  1980  			SSP_WRITE_BITS(chip->cr0, chip_info->iface,
556f4aeb7d9dfac drivers/spi/amba-pl022.c Linus Walleij            2010-05-05  1981  				       SSP_CR0_MASK_FRF_ST, 21);
781c7b129b1beb8 drivers/spi/amba-pl022.c Linus Walleij            2010-05-07  1982  			SSP_WRITE_BITS(chip->cr1, chip_info->wait_state,
781c7b129b1beb8 drivers/spi/amba-pl022.c Linus Walleij            2010-05-07  1983  				       SSP_CR1_MASK_MWAIT_ST, 6);
781c7b129b1beb8 drivers/spi/amba-pl022.c Linus Walleij            2010-05-07  1984  		}
bde435a9ca376d0 drivers/spi/amba-pl022.c Kevin Wells              2010-09-16  1985  		SSP_WRITE_BITS(chip->cr0, bits - 1,
781c7b129b1beb8 drivers/spi/amba-pl022.c Linus Walleij            2010-05-07  1986  			       SSP_CR0_MASK_DSS_ST, 0);
bde435a9ca376d0 drivers/spi/amba-pl022.c Kevin Wells              2010-09-16  1987  
bde435a9ca376d0 drivers/spi/amba-pl022.c Kevin Wells              2010-09-16  1988  		if (spi->mode & SPI_LSB_FIRST) {
bde435a9ca376d0 drivers/spi/amba-pl022.c Kevin Wells              2010-09-16  1989  			tmp = SSP_RX_LSB;
bde435a9ca376d0 drivers/spi/amba-pl022.c Kevin Wells              2010-09-16  1990  			etx = SSP_TX_LSB;
bde435a9ca376d0 drivers/spi/amba-pl022.c Kevin Wells              2010-09-16  1991  		} else {
bde435a9ca376d0 drivers/spi/amba-pl022.c Kevin Wells              2010-09-16  1992  			tmp = SSP_RX_MSB;
bde435a9ca376d0 drivers/spi/amba-pl022.c Kevin Wells              2010-09-16  1993  			etx = SSP_TX_MSB;
bde435a9ca376d0 drivers/spi/amba-pl022.c Kevin Wells              2010-09-16  1994  		}
bde435a9ca376d0 drivers/spi/amba-pl022.c Kevin Wells              2010-09-16  1995  		SSP_WRITE_BITS(chip->cr1, tmp, SSP_CR1_MASK_RENDN_ST, 4);
bde435a9ca376d0 drivers/spi/amba-pl022.c Kevin Wells              2010-09-16  1996  		SSP_WRITE_BITS(chip->cr1, etx, SSP_CR1_MASK_TENDN_ST, 5);
556f4aeb7d9dfac drivers/spi/amba-pl022.c Linus Walleij            2010-05-05  1997  		SSP_WRITE_BITS(chip->cr1, chip_info->rx_lev_trig,
556f4aeb7d9dfac drivers/spi/amba-pl022.c Linus Walleij            2010-05-05  1998  			       SSP_CR1_MASK_RXIFLSEL_ST, 7);
556f4aeb7d9dfac drivers/spi/amba-pl022.c Linus Walleij            2010-05-05  1999  		SSP_WRITE_BITS(chip->cr1, chip_info->tx_lev_trig,
556f4aeb7d9dfac drivers/spi/amba-pl022.c Linus Walleij            2010-05-05  2000  			       SSP_CR1_MASK_TXIFLSEL_ST, 10);
556f4aeb7d9dfac drivers/spi/amba-pl022.c Linus Walleij            2010-05-05  2001  	} else {
bde435a9ca376d0 drivers/spi/amba-pl022.c Kevin Wells              2010-09-16  2002  		SSP_WRITE_BITS(chip->cr0, bits - 1,
556f4aeb7d9dfac drivers/spi/amba-pl022.c Linus Walleij            2010-05-05  2003  			       SSP_CR0_MASK_DSS, 0);
556f4aeb7d9dfac drivers/spi/amba-pl022.c Linus Walleij            2010-05-05  2004  		SSP_WRITE_BITS(chip->cr0, chip_info->iface,
556f4aeb7d9dfac drivers/spi/amba-pl022.c Linus Walleij            2010-05-05  2005  			       SSP_CR0_MASK_FRF, 4);
556f4aeb7d9dfac drivers/spi/amba-pl022.c Linus Walleij            2010-05-05  2006  	}
bde435a9ca376d0 drivers/spi/amba-pl022.c Kevin Wells              2010-09-16  2007  
556f4aeb7d9dfac drivers/spi/amba-pl022.c Linus Walleij            2010-05-05  2008  	/* Stuff that is common for all versions */
bde435a9ca376d0 drivers/spi/amba-pl022.c Kevin Wells              2010-09-16  2009  	if (spi->mode & SPI_CPOL)
bde435a9ca376d0 drivers/spi/amba-pl022.c Kevin Wells              2010-09-16  2010  		tmp = SSP_CLK_POL_IDLE_HIGH;
bde435a9ca376d0 drivers/spi/amba-pl022.c Kevin Wells              2010-09-16  2011  	else
bde435a9ca376d0 drivers/spi/amba-pl022.c Kevin Wells              2010-09-16  2012  		tmp = SSP_CLK_POL_IDLE_LOW;
bde435a9ca376d0 drivers/spi/amba-pl022.c Kevin Wells              2010-09-16  2013  	SSP_WRITE_BITS(chip->cr0, tmp, SSP_CR0_MASK_SPO, 6);
bde435a9ca376d0 drivers/spi/amba-pl022.c Kevin Wells              2010-09-16  2014  
bde435a9ca376d0 drivers/spi/amba-pl022.c Kevin Wells              2010-09-16  2015  	if (spi->mode & SPI_CPHA)
bde435a9ca376d0 drivers/spi/amba-pl022.c Kevin Wells              2010-09-16  2016  		tmp = SSP_CLK_SECOND_EDGE;
bde435a9ca376d0 drivers/spi/amba-pl022.c Kevin Wells              2010-09-16  2017  	else
bde435a9ca376d0 drivers/spi/amba-pl022.c Kevin Wells              2010-09-16  2018  		tmp = SSP_CLK_FIRST_EDGE;
bde435a9ca376d0 drivers/spi/amba-pl022.c Kevin Wells              2010-09-16  2019  	SSP_WRITE_BITS(chip->cr0, tmp, SSP_CR0_MASK_SPH, 7);
bde435a9ca376d0 drivers/spi/amba-pl022.c Kevin Wells              2010-09-16  2020  
f9d629c737cb668 drivers/spi/amba-pl022.c Linus Walleij            2010-10-01  2021  	SSP_WRITE_BITS(chip->cr0, clk_freq.scr, SSP_CR0_MASK_SCR, 8);
781c7b129b1beb8 drivers/spi/amba-pl022.c Linus Walleij            2010-05-07  2022  	/* Loopback is available on all versions except PL023 */
06fb01fd1dc624d drivers/spi/amba-pl022.c Philippe Langlais        2011-03-23  2023  	if (pl022->vendor->loopback) {
bde435a9ca376d0 drivers/spi/amba-pl022.c Kevin Wells              2010-09-16  2024  		if (spi->mode & SPI_LOOP)
bde435a9ca376d0 drivers/spi/amba-pl022.c Kevin Wells              2010-09-16  2025  			tmp = LOOPBACK_ENABLED;
bde435a9ca376d0 drivers/spi/amba-pl022.c Kevin Wells              2010-09-16  2026  		else
bde435a9ca376d0 drivers/spi/amba-pl022.c Kevin Wells              2010-09-16  2027  			tmp = LOOPBACK_DISABLED;
bde435a9ca376d0 drivers/spi/amba-pl022.c Kevin Wells              2010-09-16  2028  		SSP_WRITE_BITS(chip->cr1, tmp, SSP_CR1_MASK_LBM, 0);
bde435a9ca376d0 drivers/spi/amba-pl022.c Kevin Wells              2010-09-16  2029  	}
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  2030  	SSP_WRITE_BITS(chip->cr1, SSP_DISABLED, SSP_CR1_MASK_SSE, 1);
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  2031  	SSP_WRITE_BITS(chip->cr1, chip_info->hierarchy, SSP_CR1_MASK_MS, 2);
f1e45f86ed93b9e drivers/spi/spi-pl022.c  Viresh Kumar             2011-08-10  2032  	SSP_WRITE_BITS(chip->cr1, chip_info->slave_tx_disable, SSP_CR1_MASK_SOD,
f1e45f86ed93b9e drivers/spi/spi-pl022.c  Viresh Kumar             2011-08-10  2033  		3);
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  2034  
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  2035  	/* Save controller_state */
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  2036  	spi_set_ctldata(spi, chip);
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  2037  	return status;
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  2038   err_config_params:
bde435a9ca376d0 drivers/spi/amba-pl022.c Kevin Wells              2010-09-16  2039  	spi_set_ctldata(spi, NULL);
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  2040  	kfree(chip);
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  2041  	return status;
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  2042  }
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  2043  
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  2044  /**
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  2045   * pl022_cleanup - cleanup function registered to SPI master framework
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  2046   * @spi: spi device which is requesting cleanup
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  2047   *
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  2048   * This function is registered to the SPI framework for this SPI master
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  2049   * controller. It will free the runtime state of chip.
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  2050   */
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  2051  static void pl022_cleanup(struct spi_device *spi)
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  2052  {
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  2053  	struct chip_data *chip = spi_get_ctldata(spi);
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  2054  
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  2055  	spi_set_ctldata(spi, NULL);
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  2056  	kfree(chip);
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  2057  }
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  2058  
39a6ac11df6579d drivers/spi/spi-pl022.c  Roland Stigge            2012-09-18  2059  static struct pl022_ssp_controller *
39a6ac11df6579d drivers/spi/spi-pl022.c  Roland Stigge            2012-09-18  2060  pl022_platform_data_dt_get(struct device *dev)
39a6ac11df6579d drivers/spi/spi-pl022.c  Roland Stigge            2012-09-18  2061  {
39a6ac11df6579d drivers/spi/spi-pl022.c  Roland Stigge            2012-09-18  2062  	struct device_node *np = dev->of_node;
39a6ac11df6579d drivers/spi/spi-pl022.c  Roland Stigge            2012-09-18  2063  	struct pl022_ssp_controller *pd;
849794c50b24b93 drivers/spi/spi-pl022.c  Rabin Vincent            2017-04-06  2064  	u32 tmp = 0;
39a6ac11df6579d drivers/spi/spi-pl022.c  Roland Stigge            2012-09-18  2065  
39a6ac11df6579d drivers/spi/spi-pl022.c  Roland Stigge            2012-09-18  2066  	if (!np) {
39a6ac11df6579d drivers/spi/spi-pl022.c  Roland Stigge            2012-09-18  2067  		dev_err(dev, "no dt node defined\n");
39a6ac11df6579d drivers/spi/spi-pl022.c  Roland Stigge            2012-09-18  2068  		return NULL;
39a6ac11df6579d drivers/spi/spi-pl022.c  Roland Stigge            2012-09-18  2069  	}
39a6ac11df6579d drivers/spi/spi-pl022.c  Roland Stigge            2012-09-18  2070  
39a6ac11df6579d drivers/spi/spi-pl022.c  Roland Stigge            2012-09-18  2071  	pd = devm_kzalloc(dev, sizeof(struct pl022_ssp_controller), GFP_KERNEL);
77538f4a98dc542 drivers/spi/spi-pl022.c  Jingoo Han               2014-04-29  2072  	if (!pd)
39a6ac11df6579d drivers/spi/spi-pl022.c  Roland Stigge            2012-09-18  2073  		return NULL;
39a6ac11df6579d drivers/spi/spi-pl022.c  Roland Stigge            2012-09-18  2074  
39a6ac11df6579d drivers/spi/spi-pl022.c  Roland Stigge            2012-09-18  2075  	pd->bus_id = -1;
dbd897b9c6fac8b drivers/spi/spi-pl022.c  Linus Walleij            2013-05-23  2076  	pd->enable_dma = 1;
39a6ac11df6579d drivers/spi/spi-pl022.c  Roland Stigge            2012-09-18  2077  	of_property_read_u32(np, "num-cs", &tmp);
39a6ac11df6579d drivers/spi/spi-pl022.c  Roland Stigge            2012-09-18  2078  	pd->num_chipselect = tmp;
39a6ac11df6579d drivers/spi/spi-pl022.c  Roland Stigge            2012-09-18  2079  	of_property_read_u32(np, "pl022,autosuspend-delay",
39a6ac11df6579d drivers/spi/spi-pl022.c  Roland Stigge            2012-09-18  2080  			     &pd->autosuspend_delay);
39a6ac11df6579d drivers/spi/spi-pl022.c  Roland Stigge            2012-09-18  2081  	pd->rt = of_property_read_bool(np, "pl022,rt");
39a6ac11df6579d drivers/spi/spi-pl022.c  Roland Stigge            2012-09-18  2082  
39a6ac11df6579d drivers/spi/spi-pl022.c  Roland Stigge            2012-09-18  2083  	return pd;
39a6ac11df6579d drivers/spi/spi-pl022.c  Roland Stigge            2012-09-18  2084  }
39a6ac11df6579d drivers/spi/spi-pl022.c  Roland Stigge            2012-09-18  2085  
fd4a319bc933ae9 drivers/spi/spi-pl022.c  Grant Likely             2012-12-07  2086  static int pl022_probe(struct amba_device *adev, const struct amba_id *id)
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  2087  {
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  2088  	struct device *dev = &adev->dev;
8074cf063e410a2 drivers/spi/spi-pl022.c  Jingoo Han               2013-07-30  2089  	struct pl022_ssp_controller *platform_info =
8074cf063e410a2 drivers/spi/spi-pl022.c  Jingoo Han               2013-07-30  2090  			dev_get_platdata(&adev->dev);
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  2091  	struct spi_master *master;
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  2092  	struct pl022 *pl022 = NULL;	/*Data for this driver */
6d3952a7dfa8091 drivers/spi/spi-pl022.c  Roland Stigge            2012-08-22  2093  	struct device_node *np = adev->dev.of_node;
6d3952a7dfa8091 drivers/spi/spi-pl022.c  Roland Stigge            2012-08-22  2094  	int status = 0, i, num_cs;
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  2095  
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  2096  	dev_info(&adev->dev,
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  2097  		 "ARM PL022 driver, device ID: 0x%08x\n", adev->periphid);
39a6ac11df6579d drivers/spi/spi-pl022.c  Roland Stigge            2012-09-18  2098  	if (!platform_info && IS_ENABLED(CONFIG_OF))
39a6ac11df6579d drivers/spi/spi-pl022.c  Roland Stigge            2012-09-18  2099  		platform_info = pl022_platform_data_dt_get(dev);
39a6ac11df6579d drivers/spi/spi-pl022.c  Roland Stigge            2012-09-18  2100  
39a6ac11df6579d drivers/spi/spi-pl022.c  Roland Stigge            2012-09-18  2101  	if (!platform_info) {
39a6ac11df6579d drivers/spi/spi-pl022.c  Roland Stigge            2012-09-18  2102  		dev_err(dev, "probe: no platform data defined\n");
aeef9915b9a40d2 drivers/spi/spi-pl022.c  Linus Walleij            2012-09-26  2103  		return -ENODEV;
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  2104  	}
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  2105  
6d3952a7dfa8091 drivers/spi/spi-pl022.c  Roland Stigge            2012-08-22  2106  	if (platform_info->num_chipselect) {
6d3952a7dfa8091 drivers/spi/spi-pl022.c  Roland Stigge            2012-08-22  2107  		num_cs = platform_info->num_chipselect;
6d3952a7dfa8091 drivers/spi/spi-pl022.c  Roland Stigge            2012-08-22  2108  	} else {
39a6ac11df6579d drivers/spi/spi-pl022.c  Roland Stigge            2012-09-18  2109  		dev_err(dev, "probe: no chip select defined\n");
aeef9915b9a40d2 drivers/spi/spi-pl022.c  Linus Walleij            2012-09-26  2110  		return -ENODEV;
6d3952a7dfa8091 drivers/spi/spi-pl022.c  Roland Stigge            2012-08-22  2111  	}
6d3952a7dfa8091 drivers/spi/spi-pl022.c  Roland Stigge            2012-08-22  2112  
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  2113  	/* Allocate master with space for data */
b4b8482690d97ea drivers/spi/spi-pl022.c  Roland Stigge            2012-09-03  2114  	master = spi_alloc_master(dev, sizeof(struct pl022));
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  2115  	if (master == NULL) {
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  2116  		dev_err(&adev->dev, "probe - cannot alloc SPI master\n");
aeef9915b9a40d2 drivers/spi/spi-pl022.c  Linus Walleij            2012-09-26  2117  		return -ENOMEM;
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  2118  	}
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  2119  
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  2120  	pl022 = spi_master_get_devdata(master);
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  2121  	pl022->master = master;
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  2122  	pl022->master_info = platform_info;
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  2123  	pl022->adev = adev;
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  2124  	pl022->vendor = id->data;
a86854d0c599b32 drivers/spi/spi-pl022.c  Kees Cook                2018-06-12  2125  	pl022->chipselects = devm_kcalloc(dev, num_cs, sizeof(int),
b4b8482690d97ea drivers/spi/spi-pl022.c  Roland Stigge            2012-09-03  2126  					  GFP_KERNEL);
73e3f1eb5188830 drivers/spi/spi-pl022.c  Kiran Padwal             2014-09-18  2127  	if (!pl022->chipselects) {
73e3f1eb5188830 drivers/spi/spi-pl022.c  Kiran Padwal             2014-09-18  2128  		status = -ENOMEM;
73e3f1eb5188830 drivers/spi/spi-pl022.c  Kiran Padwal             2014-09-18  2129  		goto err_no_mem;
73e3f1eb5188830 drivers/spi/spi-pl022.c  Kiran Padwal             2014-09-18  2130  	}
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  2131  
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  2132  	/*
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  2133  	 * Bus Number Which has been Assigned to this SSP controller
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  2134  	 * on this board
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  2135  	 */
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  2136  	master->bus_num = platform_info->bus_id;
6e5614b6476001a drivers/spi/spi-pl022.c  Linus Walleij            2019-06-25  2137  	master->use_gpio_descriptors;
6d3952a7dfa8091 drivers/spi/spi-pl022.c  Roland Stigge            2012-08-22  2138  	master->num_chipselect = num_cs;
6e5614b6476001a drivers/spi/spi-pl022.c  Linus Walleij            2019-06-25  2139  	master->set_cs = pl022_set_cs;
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  2140  	master->cleanup = pl022_cleanup;
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  2141  	master->setup = pl022_setup;
29b6e906a70a47c drivers/spi/spi-pl022.c  Mark Brown               2013-07-28  2142  	master->auto_runtime_pm = true;
ffbbdd21329f3e1 drivers/spi/spi-pl022.c  Linus Walleij            2012-02-22  2143  	master->transfer_one_message = pl022_transfer_one_message;
ffbbdd21329f3e1 drivers/spi/spi-pl022.c  Linus Walleij            2012-02-22  2144  	master->unprepare_transfer_hardware = pl022_unprepare_transfer_hardware;
ffbbdd21329f3e1 drivers/spi/spi-pl022.c  Linus Walleij            2012-02-22  2145  	master->rt = platform_info->rt;
6d3952a7dfa8091 drivers/spi/spi-pl022.c  Roland Stigge            2012-08-22  2146  	master->dev.of_node = dev->of_node;
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  2147  
516843702bb5fd8 drivers/spi/spi-pl022.c  Linus Walleij            2019-04-28  2148  	if (pl022->vendor->internal_cs_ctrl) {
db4fa45ed3182d8 drivers/spi/spi-pl022.c  Anders Berg              2014-09-17  2149  		for (i = 0; i < num_cs; i++)
db4fa45ed3182d8 drivers/spi/spi-pl022.c  Anders Berg              2014-09-17  2150  			pl022->chipselects[i] = i;
6d3952a7dfa8091 drivers/spi/spi-pl022.c  Roland Stigge            2012-08-22  2151  	} else if (IS_ENABLED(CONFIG_OF)) {
6d3952a7dfa8091 drivers/spi/spi-pl022.c  Roland Stigge            2012-08-22  2152  		for (i = 0; i < num_cs; i++) {
6d3952a7dfa8091 drivers/spi/spi-pl022.c  Roland Stigge            2012-08-22  2153  			int cs_gpio = of_get_named_gpio(np, "cs-gpios", i);
6d3952a7dfa8091 drivers/spi/spi-pl022.c  Roland Stigge            2012-08-22  2154  
6d3952a7dfa8091 drivers/spi/spi-pl022.c  Roland Stigge            2012-08-22  2155  			if (cs_gpio == -EPROBE_DEFER) {
6d3952a7dfa8091 drivers/spi/spi-pl022.c  Roland Stigge            2012-08-22  2156  				status = -EPROBE_DEFER;
6d3952a7dfa8091 drivers/spi/spi-pl022.c  Roland Stigge            2012-08-22  2157  				goto err_no_gpio;
6d3952a7dfa8091 drivers/spi/spi-pl022.c  Roland Stigge            2012-08-22  2158  			}
6d3952a7dfa8091 drivers/spi/spi-pl022.c  Roland Stigge            2012-08-22  2159  
6d3952a7dfa8091 drivers/spi/spi-pl022.c  Roland Stigge            2012-08-22  2160  			pl022->chipselects[i] = cs_gpio;
6d3952a7dfa8091 drivers/spi/spi-pl022.c  Roland Stigge            2012-08-22  2161  
6d3952a7dfa8091 drivers/spi/spi-pl022.c  Roland Stigge            2012-08-22  2162  			if (gpio_is_valid(cs_gpio)) {
aeef9915b9a40d2 drivers/spi/spi-pl022.c  Linus Walleij            2012-09-26  2163  				if (devm_gpio_request(dev, cs_gpio, "ssp-pl022"))
6d3952a7dfa8091 drivers/spi/spi-pl022.c  Roland Stigge            2012-08-22  2164  					dev_err(&adev->dev,
6d3952a7dfa8091 drivers/spi/spi-pl022.c  Roland Stigge            2012-08-22  2165  						"could not request %d gpio\n",
6d3952a7dfa8091 drivers/spi/spi-pl022.c  Roland Stigge            2012-08-22  2166  						cs_gpio);
6d3952a7dfa8091 drivers/spi/spi-pl022.c  Roland Stigge            2012-08-22  2167  				else if (gpio_direction_output(cs_gpio, 1))
6d3952a7dfa8091 drivers/spi/spi-pl022.c  Roland Stigge            2012-08-22  2168  					dev_err(&adev->dev,
61e89e65e31516c drivers/spi/spi-pl022.c  Roland Stigge            2014-09-09  2169  						"could not set gpio %d as output\n",
6d3952a7dfa8091 drivers/spi/spi-pl022.c  Roland Stigge            2012-08-22  2170  						cs_gpio);
6d3952a7dfa8091 drivers/spi/spi-pl022.c  Roland Stigge            2012-08-22  2171  			}
6d3952a7dfa8091 drivers/spi/spi-pl022.c  Roland Stigge            2012-08-22  2172  		}
6d3952a7dfa8091 drivers/spi/spi-pl022.c  Roland Stigge            2012-08-22  2173  	}
f6f46de1063c882 drivers/spi/spi-pl022.c  Roland Stigge            2012-08-22  2174  
bde435a9ca376d0 drivers/spi/amba-pl022.c Kevin Wells              2010-09-16  2175  	/*
bde435a9ca376d0 drivers/spi/amba-pl022.c Kevin Wells              2010-09-16  2176  	 * Supports mode 0-3, loopback, and active low CS. Transfers are
bde435a9ca376d0 drivers/spi/amba-pl022.c Kevin Wells              2010-09-16  2177  	 * always MS bit first on the original pl022.
bde435a9ca376d0 drivers/spi/amba-pl022.c Kevin Wells              2010-09-16  2178  	 */
bde435a9ca376d0 drivers/spi/amba-pl022.c Kevin Wells              2010-09-16  2179  	master->mode_bits = SPI_CPOL | SPI_CPHA | SPI_CS_HIGH | SPI_LOOP;
bde435a9ca376d0 drivers/spi/amba-pl022.c Kevin Wells              2010-09-16  2180  	if (pl022->vendor->extended_cr)
bde435a9ca376d0 drivers/spi/amba-pl022.c Kevin Wells              2010-09-16  2181  		master->mode_bits |= SPI_LSB_FIRST;
bde435a9ca376d0 drivers/spi/amba-pl022.c Kevin Wells              2010-09-16  2182  
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  2183  	dev_dbg(&adev->dev, "BUSNO: %d\n", master->bus_num);
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  2184  
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  2185  	status = amba_request_regions(adev, NULL);
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  2186  	if (status)
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  2187  		goto err_no_ioregion;
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  2188  
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29  2189  	pl022->phybase = adev->res.start;
aeef9915b9a40d2 drivers/spi/spi-pl022.c  Linus Walleij            2012-09-26  2190  	pl022->virtbase = devm_ioremap(dev, adev->res.start,
aeef9915b9a40d2 drivers/spi/spi-pl022.c  Linus Walleij            2012-09-26  2191  				       resource_size(&adev->res));
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  2192  	if (pl022->virtbase == NULL) {
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  2193  		status = -ENOMEM;
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  2194  		goto err_no_ioremap;
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  2195  	}
2c067509a1e3540 drivers/spi/spi-pl022.c  Jingoo Han               2013-10-11  2196  	dev_info(&adev->dev, "mapped registers from %pa to %p\n",
7085f403517615c drivers/spi/spi-pl022.c  Fabio Estevam            2013-08-21  2197  		&adev->res.start, pl022->virtbase);
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  2198  
aeef9915b9a40d2 drivers/spi/spi-pl022.c  Linus Walleij            2012-09-26  2199  	pl022->clk = devm_clk_get(&adev->dev, NULL);
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  2200  	if (IS_ERR(pl022->clk)) {
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  2201  		status = PTR_ERR(pl022->clk);
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  2202  		dev_err(&adev->dev, "could not retrieve SSP/SPI bus clock\n");
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  2203  		goto err_no_clk;
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  2204  	}
7ff6bcf048e6a98 drivers/spi/spi-pl022.c  Russell King             2011-09-22  2205  
6cac167b826eced drivers/spi/spi-pl022.c  Ulf Hansson              2014-02-04  2206  	status = clk_prepare_enable(pl022->clk);
71e63e748ee6f4b drivers/spi/spi-pl022.c  Ulf Hansson              2011-11-04  2207  	if (status) {
71e63e748ee6f4b drivers/spi/spi-pl022.c  Ulf Hansson              2011-11-04  2208  		dev_err(&adev->dev, "could not enable SSP/SPI bus clock\n");
71e63e748ee6f4b drivers/spi/spi-pl022.c  Ulf Hansson              2011-11-04  2209  		goto err_no_clk_en;
71e63e748ee6f4b drivers/spi/spi-pl022.c  Ulf Hansson              2011-11-04  2210  	}
71e63e748ee6f4b drivers/spi/spi-pl022.c  Ulf Hansson              2011-11-04  2211  
ffbbdd21329f3e1 drivers/spi/spi-pl022.c  Linus Walleij            2012-02-22  2212  	/* Initialize transfer pump */
ffbbdd21329f3e1 drivers/spi/spi-pl022.c  Linus Walleij            2012-02-22  2213  	tasklet_init(&pl022->pump_transfers, pump_transfers,
ffbbdd21329f3e1 drivers/spi/spi-pl022.c  Linus Walleij            2012-02-22  2214  		     (unsigned long)pl022);
ffbbdd21329f3e1 drivers/spi/spi-pl022.c  Linus Walleij            2012-02-22  2215  
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  2216  	/* Disable SSP */
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  2217  	writew((readw(SSP_CR1(pl022->virtbase)) & (~SSP_CR1_MASK_SSE)),
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  2218  	       SSP_CR1(pl022->virtbase));
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  2219  	load_ssp_default_config(pl022);
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  2220  
aeef9915b9a40d2 drivers/spi/spi-pl022.c  Linus Walleij            2012-09-26  2221  	status = devm_request_irq(dev, adev->irq[0], pl022_interrupt_handler,
aeef9915b9a40d2 drivers/spi/spi-pl022.c  Linus Walleij            2012-09-26  2222  				  0, "pl022", pl022);
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  2223  	if (status < 0) {
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  2224  		dev_err(&adev->dev, "probe - cannot get IRQ (%d)\n", status);
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  2225  		goto err_no_irq;
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  2226  	}
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29  2227  
dc715452e914515 drivers/spi/spi-pl022.c  Arnd Bergmann            2013-01-28  2228  	/* Get DMA channels, try autoconfiguration first */
dc715452e914515 drivers/spi/spi-pl022.c  Arnd Bergmann            2013-01-28  2229  	status = pl022_dma_autoprobe(pl022);
f3d4bb3342630cd drivers/spi/spi-pl022.c  Rabin Vincent            2015-11-23  2230  	if (status == -EPROBE_DEFER) {
f3d4bb3342630cd drivers/spi/spi-pl022.c  Rabin Vincent            2015-11-23  2231  		dev_dbg(dev, "deferring probe to get DMA channel\n");
f3d4bb3342630cd drivers/spi/spi-pl022.c  Rabin Vincent            2015-11-23  2232  		goto err_no_irq;
f3d4bb3342630cd drivers/spi/spi-pl022.c  Rabin Vincent            2015-11-23  2233  	}
dc715452e914515 drivers/spi/spi-pl022.c  Arnd Bergmann            2013-01-28  2234  
dc715452e914515 drivers/spi/spi-pl022.c  Arnd Bergmann            2013-01-28  2235  	/* If that failed, use channels from platform_info */
dc715452e914515 drivers/spi/spi-pl022.c  Arnd Bergmann            2013-01-28  2236  	if (status == 0)
dc715452e914515 drivers/spi/spi-pl022.c  Arnd Bergmann            2013-01-28  2237  		platform_info->enable_dma = 1;
dc715452e914515 drivers/spi/spi-pl022.c  Arnd Bergmann            2013-01-28  2238  	else if (platform_info->enable_dma) {
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29  2239  		status = pl022_dma_probe(pl022);
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29  2240  		if (status != 0)
43c640157d4366a drivers/spi/amba-pl022.c Viresh Kumar             2011-05-16  2241  			platform_info->enable_dma = 0;
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29  2242  	}
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29  2243  
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  2244  	/* Register with the SPI framework */
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  2245  	amba_set_drvdata(adev, pl022);
35794a77168b739 drivers/spi/spi-pl022.c  Jingoo Han               2013-09-24  2246  	status = devm_spi_register_master(&adev->dev, master);
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  2247  	if (status != 0) {
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  2248  		dev_err(&adev->dev,
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  2249  			"probe - problem registering spi master\n");
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  2250  		goto err_spi_register;
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  2251  	}
25985edcedea639 drivers/spi/amba-pl022.c Lucas De Marchi          2011-03-30  2252  	dev_dbg(dev, "probe succeeded\n");
92b97f0aaccbf9d drivers/spi/spi-pl022.c  Russell King             2011-08-14  2253  
92b97f0aaccbf9d drivers/spi/spi-pl022.c  Russell King             2011-08-14  2254  	/* let runtime pm put suspend */
53e4acea0e819a6 drivers/spi/spi-pl022.c  Chris Blair              2011-11-08  2255  	if (platform_info->autosuspend_delay > 0) {
53e4acea0e819a6 drivers/spi/spi-pl022.c  Chris Blair              2011-11-08  2256  		dev_info(&adev->dev,
53e4acea0e819a6 drivers/spi/spi-pl022.c  Chris Blair              2011-11-08  2257  			"will use autosuspend for runtime pm, delay %dms\n",
53e4acea0e819a6 drivers/spi/spi-pl022.c  Chris Blair              2011-11-08  2258  			platform_info->autosuspend_delay);
53e4acea0e819a6 drivers/spi/spi-pl022.c  Chris Blair              2011-11-08  2259  		pm_runtime_set_autosuspend_delay(dev,
53e4acea0e819a6 drivers/spi/spi-pl022.c  Chris Blair              2011-11-08  2260  			platform_info->autosuspend_delay);
53e4acea0e819a6 drivers/spi/spi-pl022.c  Chris Blair              2011-11-08  2261  		pm_runtime_use_autosuspend(dev);
53e4acea0e819a6 drivers/spi/spi-pl022.c  Chris Blair              2011-11-08  2262  	}
0df349945752bf0 drivers/spi/spi-pl022.c  Ulf Hansson              2012-10-17  2263  	pm_runtime_put(dev);
0df349945752bf0 drivers/spi/spi-pl022.c  Ulf Hansson              2012-10-17  2264  
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  2265  	return 0;
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  2266  
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  2267   err_spi_register:
3e3ea716270dc64 drivers/spi/spi-pl022.c  Viresh Kumar             2011-08-10  2268  	if (platform_info->enable_dma)
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29  2269  		pl022_dma_remove(pl022);
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  2270   err_no_irq:
6cac167b826eced drivers/spi/spi-pl022.c  Ulf Hansson              2014-02-04  2271  	clk_disable_unprepare(pl022->clk);
71e63e748ee6f4b drivers/spi/spi-pl022.c  Ulf Hansson              2011-11-04  2272   err_no_clk_en:
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  2273   err_no_clk:
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  2274   err_no_ioremap:
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  2275  	amba_release_regions(adev);
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  2276   err_no_ioregion:
6d3952a7dfa8091 drivers/spi/spi-pl022.c  Roland Stigge            2012-08-22  2277   err_no_gpio:
73e3f1eb5188830 drivers/spi/spi-pl022.c  Kiran Padwal             2014-09-18  2278   err_no_mem:
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  2279  	spi_master_put(master);
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  2280  	return status;
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  2281  }
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  2282  
fd4a319bc933ae9 drivers/spi/spi-pl022.c  Grant Likely             2012-12-07  2283  static int
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  2284  pl022_remove(struct amba_device *adev)
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  2285  {
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  2286  	struct pl022 *pl022 = amba_get_drvdata(adev);
50658b6602dad6d drivers/spi/spi-pl022.c  Linus Walleij            2011-08-02  2287  
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  2288  	if (!pl022)
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  2289  		return 0;
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  2290  
92b97f0aaccbf9d drivers/spi/spi-pl022.c  Russell King             2011-08-14  2291  	/*
92b97f0aaccbf9d drivers/spi/spi-pl022.c  Russell King             2011-08-14  2292  	 * undo pm_runtime_put() in probe.  I assume that we're not
92b97f0aaccbf9d drivers/spi/spi-pl022.c  Russell King             2011-08-14  2293  	 * accessing the primecell here.
92b97f0aaccbf9d drivers/spi/spi-pl022.c  Russell King             2011-08-14  2294  	 */
92b97f0aaccbf9d drivers/spi/spi-pl022.c  Russell King             2011-08-14  2295  	pm_runtime_get_noresume(&adev->dev);
92b97f0aaccbf9d drivers/spi/spi-pl022.c  Russell King             2011-08-14  2296  
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  2297  	load_ssp_default_config(pl022);
3e3ea716270dc64 drivers/spi/spi-pl022.c  Viresh Kumar             2011-08-10  2298  	if (pl022->master_info->enable_dma)
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29  2299  		pl022_dma_remove(pl022);
3e3ea716270dc64 drivers/spi/spi-pl022.c  Viresh Kumar             2011-08-10  2300  
6cac167b826eced drivers/spi/spi-pl022.c  Ulf Hansson              2014-02-04  2301  	clk_disable_unprepare(pl022->clk);
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  2302  	amba_release_regions(adev);
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  2303  	tasklet_disable(&pl022->pump_transfers);
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  2304  	return 0;
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  2305  }
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  2306  
84a5dc41f64faad drivers/spi/spi-pl022.c  Ulf Hansson              2014-03-01  2307  #ifdef CONFIG_PM_SLEEP
6cfa6279edbffa9 drivers/spi/spi-pl022.c  Peter Hüwe               2011-09-05  2308  static int pl022_suspend(struct device *dev)
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  2309  {
92b97f0aaccbf9d drivers/spi/spi-pl022.c  Russell King             2011-08-14  2310  	struct pl022 *pl022 = dev_get_drvdata(dev);
ffbbdd21329f3e1 drivers/spi/spi-pl022.c  Linus Walleij            2012-02-22  2311  	int ret;
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  2312  
ffbbdd21329f3e1 drivers/spi/spi-pl022.c  Linus Walleij            2012-02-22  2313  	ret = spi_master_suspend(pl022->master);
7c5d8a249acadc3 drivers/spi/spi-pl022.c  Geert Uytterhoeven       2018-09-05  2314  	if (ret)
ffbbdd21329f3e1 drivers/spi/spi-pl022.c  Linus Walleij            2012-02-22  2315  		return ret;
4964a26df72c4a8 drivers/spi/spi-pl022.c  Ulf Hansson              2012-10-17  2316  
84a5dc41f64faad drivers/spi/spi-pl022.c  Ulf Hansson              2014-03-01  2317  	ret = pm_runtime_force_suspend(dev);
84a5dc41f64faad drivers/spi/spi-pl022.c  Ulf Hansson              2014-03-01  2318  	if (ret) {
84a5dc41f64faad drivers/spi/spi-pl022.c  Ulf Hansson              2014-03-01  2319  		spi_master_resume(pl022->master);
84a5dc41f64faad drivers/spi/spi-pl022.c  Ulf Hansson              2014-03-01  2320  		return ret;
84a5dc41f64faad drivers/spi/spi-pl022.c  Ulf Hansson              2014-03-01  2321  	}
84a5dc41f64faad drivers/spi/spi-pl022.c  Ulf Hansson              2014-03-01  2322  
84a5dc41f64faad drivers/spi/spi-pl022.c  Ulf Hansson              2014-03-01  2323  	pinctrl_pm_select_sleep_state(dev);
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  2324  
6cfa6279edbffa9 drivers/spi/spi-pl022.c  Peter Hüwe               2011-09-05  2325  	dev_dbg(dev, "suspended\n");
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  2326  	return 0;
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  2327  }
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  2328  
92b97f0aaccbf9d drivers/spi/spi-pl022.c  Russell King             2011-08-14  2329  static int pl022_resume(struct device *dev)
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  2330  {
92b97f0aaccbf9d drivers/spi/spi-pl022.c  Russell King             2011-08-14  2331  	struct pl022 *pl022 = dev_get_drvdata(dev);
ffbbdd21329f3e1 drivers/spi/spi-pl022.c  Linus Walleij            2012-02-22  2332  	int ret;
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  2333  
84a5dc41f64faad drivers/spi/spi-pl022.c  Ulf Hansson              2014-03-01  2334  	ret = pm_runtime_force_resume(dev);
84a5dc41f64faad drivers/spi/spi-pl022.c  Ulf Hansson              2014-03-01  2335  	if (ret)
84a5dc41f64faad drivers/spi/spi-pl022.c  Ulf Hansson              2014-03-01  2336  		dev_err(dev, "problem resuming\n");
ada7aec7eec0ca2 drivers/spi/spi-pl022.c  Linus Walleij            2012-09-26  2337  
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  2338  	/* Start the queue running */
ffbbdd21329f3e1 drivers/spi/spi-pl022.c  Linus Walleij            2012-02-22  2339  	ret = spi_master_resume(pl022->master);
7c5d8a249acadc3 drivers/spi/spi-pl022.c  Geert Uytterhoeven       2018-09-05  2340  	if (!ret)
92b97f0aaccbf9d drivers/spi/spi-pl022.c  Russell King             2011-08-14  2341  		dev_dbg(dev, "resumed\n");
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  2342  
ffbbdd21329f3e1 drivers/spi/spi-pl022.c  Linus Walleij            2012-02-22  2343  	return ret;
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  2344  }
84a5dc41f64faad drivers/spi/spi-pl022.c  Ulf Hansson              2014-03-01  2345  #endif
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  2346  
736198b0486c8d5 drivers/spi/spi-pl022.c  Ulf Hansson              2014-03-01  2347  #ifdef CONFIG_PM
92b97f0aaccbf9d drivers/spi/spi-pl022.c  Russell King             2011-08-14  2348  static int pl022_runtime_suspend(struct device *dev)
92b97f0aaccbf9d drivers/spi/spi-pl022.c  Russell King             2011-08-14  2349  {
92b97f0aaccbf9d drivers/spi/spi-pl022.c  Russell King             2011-08-14  2350  	struct pl022 *pl022 = dev_get_drvdata(dev);
4f5e1b370845a0a drivers/spi/spi-pl022.c  Patrice Chotard          2012-09-19  2351  
84a5dc41f64faad drivers/spi/spi-pl022.c  Ulf Hansson              2014-03-01  2352  	clk_disable_unprepare(pl022->clk);
84a5dc41f64faad drivers/spi/spi-pl022.c  Ulf Hansson              2014-03-01  2353  	pinctrl_pm_select_idle_state(dev);
84a5dc41f64faad drivers/spi/spi-pl022.c  Ulf Hansson              2014-03-01  2354  
92b97f0aaccbf9d drivers/spi/spi-pl022.c  Russell King             2011-08-14  2355  	return 0;
92b97f0aaccbf9d drivers/spi/spi-pl022.c  Russell King             2011-08-14  2356  }
92b97f0aaccbf9d drivers/spi/spi-pl022.c  Russell King             2011-08-14  2357  
92b97f0aaccbf9d drivers/spi/spi-pl022.c  Russell King             2011-08-14  2358  static int pl022_runtime_resume(struct device *dev)
92b97f0aaccbf9d drivers/spi/spi-pl022.c  Russell King             2011-08-14  2359  {
92b97f0aaccbf9d drivers/spi/spi-pl022.c  Russell King             2011-08-14  2360  	struct pl022 *pl022 = dev_get_drvdata(dev);
92b97f0aaccbf9d drivers/spi/spi-pl022.c  Russell King             2011-08-14  2361  
84a5dc41f64faad drivers/spi/spi-pl022.c  Ulf Hansson              2014-03-01  2362  	pinctrl_pm_select_default_state(dev);
84a5dc41f64faad drivers/spi/spi-pl022.c  Ulf Hansson              2014-03-01  2363  	clk_prepare_enable(pl022->clk);
84a5dc41f64faad drivers/spi/spi-pl022.c  Ulf Hansson              2014-03-01  2364  
92b97f0aaccbf9d drivers/spi/spi-pl022.c  Russell King             2011-08-14  2365  	return 0;
92b97f0aaccbf9d drivers/spi/spi-pl022.c  Russell King             2011-08-14  2366  }
92b97f0aaccbf9d drivers/spi/spi-pl022.c  Russell King             2011-08-14  2367  #endif
92b97f0aaccbf9d drivers/spi/spi-pl022.c  Russell King             2011-08-14  2368  
92b97f0aaccbf9d drivers/spi/spi-pl022.c  Russell King             2011-08-14  2369  static const struct dev_pm_ops pl022_dev_pm_ops = {
92b97f0aaccbf9d drivers/spi/spi-pl022.c  Russell King             2011-08-14  2370  	SET_SYSTEM_SLEEP_PM_OPS(pl022_suspend, pl022_resume)
6ed23b806e73bdd drivers/spi/spi-pl022.c  Rafael J. Wysocki        2014-12-04  2371  	SET_RUNTIME_PM_OPS(pl022_runtime_suspend, pl022_runtime_resume, NULL)
92b97f0aaccbf9d drivers/spi/spi-pl022.c  Russell King             2011-08-14  2372  };
92b97f0aaccbf9d drivers/spi/spi-pl022.c  Russell King             2011-08-14  2373  
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  2374  static struct vendor_data vendor_arm = {
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  2375  	.fifodepth = 8,
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  2376  	.max_bpw = 16,
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  2377  	.unidir = false,
556f4aeb7d9dfac drivers/spi/amba-pl022.c Linus Walleij            2010-05-05  2378  	.extended_cr = false,
781c7b129b1beb8 drivers/spi/amba-pl022.c Linus Walleij            2010-05-07  2379  	.pl023 = false,
06fb01fd1dc624d drivers/spi/amba-pl022.c Philippe Langlais        2011-03-23  2380  	.loopback = true,
db4fa45ed3182d8 drivers/spi/spi-pl022.c  Anders Berg              2014-09-17  2381  	.internal_cs_ctrl = false,
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  2382  };
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  2383  
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  2384  static struct vendor_data vendor_st = {
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  2385  	.fifodepth = 32,
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  2386  	.max_bpw = 32,
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  2387  	.unidir = false,
556f4aeb7d9dfac drivers/spi/amba-pl022.c Linus Walleij            2010-05-05  2388  	.extended_cr = true,
781c7b129b1beb8 drivers/spi/amba-pl022.c Linus Walleij            2010-05-07  2389  	.pl023 = false,
06fb01fd1dc624d drivers/spi/amba-pl022.c Philippe Langlais        2011-03-23  2390  	.loopback = true,
db4fa45ed3182d8 drivers/spi/spi-pl022.c  Anders Berg              2014-09-17  2391  	.internal_cs_ctrl = false,
781c7b129b1beb8 drivers/spi/amba-pl022.c Linus Walleij            2010-05-07  2392  };
781c7b129b1beb8 drivers/spi/amba-pl022.c Linus Walleij            2010-05-07  2393  
781c7b129b1beb8 drivers/spi/amba-pl022.c Linus Walleij            2010-05-07  2394  static struct vendor_data vendor_st_pl023 = {
781c7b129b1beb8 drivers/spi/amba-pl022.c Linus Walleij            2010-05-07  2395  	.fifodepth = 32,
781c7b129b1beb8 drivers/spi/amba-pl022.c Linus Walleij            2010-05-07  2396  	.max_bpw = 32,
781c7b129b1beb8 drivers/spi/amba-pl022.c Linus Walleij            2010-05-07  2397  	.unidir = false,
781c7b129b1beb8 drivers/spi/amba-pl022.c Linus Walleij            2010-05-07  2398  	.extended_cr = true,
781c7b129b1beb8 drivers/spi/amba-pl022.c Linus Walleij            2010-05-07  2399  	.pl023 = true,
06fb01fd1dc624d drivers/spi/amba-pl022.c Philippe Langlais        2011-03-23  2400  	.loopback = false,
db4fa45ed3182d8 drivers/spi/spi-pl022.c  Anders Berg              2014-09-17  2401  	.internal_cs_ctrl = false,
db4fa45ed3182d8 drivers/spi/spi-pl022.c  Anders Berg              2014-09-17  2402  };
db4fa45ed3182d8 drivers/spi/spi-pl022.c  Anders Berg              2014-09-17  2403  
db4fa45ed3182d8 drivers/spi/spi-pl022.c  Anders Berg              2014-09-17  2404  static struct vendor_data vendor_lsi = {
db4fa45ed3182d8 drivers/spi/spi-pl022.c  Anders Berg              2014-09-17  2405  	.fifodepth = 8,
db4fa45ed3182d8 drivers/spi/spi-pl022.c  Anders Berg              2014-09-17  2406  	.max_bpw = 16,
db4fa45ed3182d8 drivers/spi/spi-pl022.c  Anders Berg              2014-09-17  2407  	.unidir = false,
db4fa45ed3182d8 drivers/spi/spi-pl022.c  Anders Berg              2014-09-17  2408  	.extended_cr = false,
db4fa45ed3182d8 drivers/spi/spi-pl022.c  Anders Berg              2014-09-17  2409  	.pl023 = false,
db4fa45ed3182d8 drivers/spi/spi-pl022.c  Anders Berg              2014-09-17  2410  	.loopback = true,
db4fa45ed3182d8 drivers/spi/spi-pl022.c  Anders Berg              2014-09-17  2411  	.internal_cs_ctrl = true,
06fb01fd1dc624d drivers/spi/amba-pl022.c Philippe Langlais        2011-03-23  2412  };
06fb01fd1dc624d drivers/spi/amba-pl022.c Philippe Langlais        2011-03-23  2413  
5b8d5ad2308d2d5 drivers/spi/spi-pl022.c  Arvind Yadav             2017-08-23  2414  static const struct amba_id pl022_ids[] = {
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  2415  	{
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  2416  		/*
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  2417  		 * ARM PL022 variant, this has a 16bit wide
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  2418  		 * and 8 locations deep TX/RX FIFO
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  2419  		 */
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  2420  		.id	= 0x00041022,
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  2421  		.mask	= 0x000fffff,
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  2422  		.data	= &vendor_arm,
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  2423  	},
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  2424  	{
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  2425  		/*
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  2426  		 * ST Micro derivative, this has 32bit wide
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  2427  		 * and 32 locations deep TX/RX FIFO
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  2428  		 */
e89e04fcdce6146 drivers/spi/amba-pl022.c Srinidhi Kasagar         2009-10-05  2429  		.id	= 0x01080022,
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  2430  		.mask	= 0xffffffff,
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  2431  		.data	= &vendor_st,
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  2432  	},
781c7b129b1beb8 drivers/spi/amba-pl022.c Linus Walleij            2010-05-07  2433  	{
781c7b129b1beb8 drivers/spi/amba-pl022.c Linus Walleij            2010-05-07  2434  		/*
781c7b129b1beb8 drivers/spi/amba-pl022.c Linus Walleij            2010-05-07  2435  		 * ST-Ericsson derivative "PL023" (this is not
781c7b129b1beb8 drivers/spi/amba-pl022.c Linus Walleij            2010-05-07  2436  		 * an official ARM number), this is a PL022 SSP block
781c7b129b1beb8 drivers/spi/amba-pl022.c Linus Walleij            2010-05-07  2437  		 * stripped to SPI mode only, it has 32bit wide
781c7b129b1beb8 drivers/spi/amba-pl022.c Linus Walleij            2010-05-07  2438  		 * and 32 locations deep TX/RX FIFO but no extended
781c7b129b1beb8 drivers/spi/amba-pl022.c Linus Walleij            2010-05-07  2439  		 * CR0/CR1 register
781c7b129b1beb8 drivers/spi/amba-pl022.c Linus Walleij            2010-05-07  2440  		 */
781c7b129b1beb8 drivers/spi/amba-pl022.c Linus Walleij            2010-05-07  2441  		.id	= 0x00080023,
781c7b129b1beb8 drivers/spi/amba-pl022.c Linus Walleij            2010-05-07  2442  		.mask	= 0xffffffff,
781c7b129b1beb8 drivers/spi/amba-pl022.c Linus Walleij            2010-05-07  2443  		.data	= &vendor_st_pl023,
781c7b129b1beb8 drivers/spi/amba-pl022.c Linus Walleij            2010-05-07  2444  	},
db4fa45ed3182d8 drivers/spi/spi-pl022.c  Anders Berg              2014-09-17  2445  	{
db4fa45ed3182d8 drivers/spi/spi-pl022.c  Anders Berg              2014-09-17  2446  		/*
db4fa45ed3182d8 drivers/spi/spi-pl022.c  Anders Berg              2014-09-17  2447  		 * PL022 variant that has a chip select control register whih
db4fa45ed3182d8 drivers/spi/spi-pl022.c  Anders Berg              2014-09-17  2448  		 * allows control of 5 output signals nCS[0:4].
db4fa45ed3182d8 drivers/spi/spi-pl022.c  Anders Berg              2014-09-17  2449  		 */
db4fa45ed3182d8 drivers/spi/spi-pl022.c  Anders Berg              2014-09-17  2450  		.id	= 0x000b6022,
db4fa45ed3182d8 drivers/spi/spi-pl022.c  Anders Berg              2014-09-17  2451  		.mask	= 0x000fffff,
db4fa45ed3182d8 drivers/spi/spi-pl022.c  Anders Berg              2014-09-17  2452  		.data	= &vendor_lsi,
db4fa45ed3182d8 drivers/spi/spi-pl022.c  Anders Berg              2014-09-17  2453  	},
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  2454  	{ 0, 0 },
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  2455  };
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  2456  
7eeac71b9fc9b3d drivers/spi/spi-pl022.c  Dave Martin              2011-10-05  2457  MODULE_DEVICE_TABLE(amba, pl022_ids);
7eeac71b9fc9b3d drivers/spi/spi-pl022.c  Dave Martin              2011-10-05  2458  
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  2459  static struct amba_driver pl022_driver = {
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  2460  	.drv = {
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  2461  		.name	= "ssp-pl022",
92b97f0aaccbf9d drivers/spi/spi-pl022.c  Russell King             2011-08-14  2462  		.pm	= &pl022_dev_pm_ops,
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  2463  	},
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  2464  	.id_table	= pl022_ids,
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  2465  	.probe		= pl022_probe,
fd4a319bc933ae9 drivers/spi/spi-pl022.c  Grant Likely             2012-12-07  2466  	.remove		= pl022_remove,
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  2467  };
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  2468  
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  2469  static int __init pl022_init(void)
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  2470  {
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  2471  	return amba_driver_register(&pl022_driver);
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  2472  }
25c8e03bdb769df drivers/spi/amba-pl022.c Linus Walleij            2010-09-06  2473  subsys_initcall(pl022_init);
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  2474  
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  2475  static void __exit pl022_exit(void)
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  2476  {
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  2477  	amba_driver_unregister(&pl022_driver);
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  2478  }
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  2479  module_exit(pl022_exit);
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  2480  
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  2481  MODULE_AUTHOR("Linus Walleij <linus.walleij@xxxxxxxxxxxxxx>");
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  2482  MODULE_DESCRIPTION("PL022 SSP Controller Driver");
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  2483  MODULE_LICENSE("GPL");

:::::: The code at line 442 was first introduced by commit
:::::: db4fa45ed3182d8206af241811dfc99369ffa849 spi: pl022: Add support for chip select extension

:::::: TO: Anders Berg <anders.berg@xxxxxxxxxxxxx>
:::::: CC: Mark Brown <broonie@xxxxxxxxxx>

---
0-DAY kernel test infrastructure                Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all                   Intel Corporation

Attachment: .config.gz
Description: application/gzip


[Index of Archives]     [Linux SPI]     [Linux Kernel]     [Linux ARM (vger)]     [Linux ARM MSM]     [Linux Omap]     [Linux Arm]     [Linux Tegra]     [Fedora ARM]     [Linux for Samsung SOC]     [eCos]     [Linux Fastboot]     [Gcc Help]     [Git]     [DCCP]     [IETF Announce]     [Security]     [Linux MIPS]     [Yosemite Campsites]

  Powered by Linux