mirror of
https://github.com/AuxXxilium/linux_dsm_epyc7002.git
synced 2024-12-23 22:41:11 +07:00
9b00bc7b90
This converts the bit-banged GPIO SPI driver to looking up and using GPIO descriptors to get a handle on GPIO lines for SCK, MOSI, MISO and all CS lines. All existing board files are converted in one go to keep it all consistent. With these conversions I rarely find any interrim steps that makes any sense. Device tree probing and GPIO handling should work like before also after this patch. For board files, we stop using controller data to pass the GPIO line for chip select, instead we pass this as a GPIO descriptor lookup like everything else. In some s3c24xx machines the names of the SPI devices were set to "spi-gpio" rather than "spi_gpio" which can never have worked, I fixed it working (I guess) as part of this patch set. Sometimes I wonder how this code got upstream in the first place, it obviously is not tested. mach-s3c64xx/mach-smartq.c has the same problem and additionally defines the *same* GPIO line for MOSI and MISO which is not going to be accepted by gpiolib. As the lines were number 1,2,2 I assumed it was a typo and use lines 1,2,3. A comment gives awat that line 0 is chip select though no actual SPI device is provided for the LCD supposed to be on this bit-banged SPI bus. I left it intact instead of just deleting the bus though. Kill off board file code that try to initialize the SPI lines to the same values that they will later be set by the spi_gpio driver anyways. Given the huge number of weird things in these board files I do not think this code is very tested or put in with much afterthought anyways. In order to assert that we do not get performance regressions on this crucial bing-banged driver, a ran a script like this dumping the Ilitek ILI9322 regmap 10000 times (it has no caching obviously) on an otherwise idle system in two iterations before and after the patches: #!/bin/sh for run in `seq 10000` do cat /debug/regmap/spi0.0/registers > /dev/null done Before the patch: time test.sh real 3m 41.03s user 0m 29.41s sys 3m 7.22s time test.sh real 3m 44.24s user 0m 32.31s sys 3m 7.60s After the patch: time test.sh real 3m 41.32s user 0m 28.92s sys 3m 8.08s time test.sh real 3m 39.92s user 0m 30.20s sys 3m 5.56s So any performance differences seems to be in the error margin. Signed-off-by: Linus Walleij <linus.walleij@linaro.org> Acked-by: Olof Johansson <olof@lixom.net> Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com> Signed-off-by: Mark Brown <broonie@kernel.org>
107 lines
2.8 KiB
C
107 lines
2.8 KiB
C
/*
|
|
* EEPROMs access control driver for display configuration EEPROMs
|
|
* on DigsyMTC board.
|
|
*
|
|
* (C) 2011 DENX Software Engineering, Anatolij Gustschin <agust@denx.de>
|
|
*
|
|
* This program is free software; you can redistribute it and/or modify
|
|
* it under the terms of the GNU General Public License version 2 as
|
|
* published by the Free Software Foundation.
|
|
*
|
|
* FIXME: this driver is used on a device-tree probed platform: it
|
|
* should be defined as a bit-banged SPI device and probed from the device
|
|
* tree and not like this with static grabbing of a few numbered GPIO
|
|
* lines at random.
|
|
*
|
|
* Add proper SPI and EEPROM in arch/powerpc/boot/dts/digsy_mtc.dts
|
|
* and delete this driver.
|
|
*/
|
|
|
|
#include <linux/gpio.h>
|
|
#include <linux/gpio/machine.h>
|
|
#include <linux/init.h>
|
|
#include <linux/platform_device.h>
|
|
#include <linux/spi/spi.h>
|
|
#include <linux/spi/spi_gpio.h>
|
|
#include <linux/eeprom_93xx46.h>
|
|
|
|
#define GPIO_EEPROM_CLK 216
|
|
#define GPIO_EEPROM_CS 210
|
|
#define GPIO_EEPROM_DI 217
|
|
#define GPIO_EEPROM_DO 249
|
|
#define GPIO_EEPROM_OE 255
|
|
#define EE_SPI_BUS_NUM 1
|
|
|
|
static void digsy_mtc_op_prepare(void *p)
|
|
{
|
|
/* enable */
|
|
gpio_set_value(GPIO_EEPROM_OE, 0);
|
|
}
|
|
|
|
static void digsy_mtc_op_finish(void *p)
|
|
{
|
|
/* disable */
|
|
gpio_set_value(GPIO_EEPROM_OE, 1);
|
|
}
|
|
|
|
struct eeprom_93xx46_platform_data digsy_mtc_eeprom_data = {
|
|
.flags = EE_ADDR8,
|
|
.prepare = digsy_mtc_op_prepare,
|
|
.finish = digsy_mtc_op_finish,
|
|
};
|
|
|
|
static struct spi_gpio_platform_data eeprom_spi_gpio_data = {
|
|
.num_chipselect = 1,
|
|
};
|
|
|
|
static struct platform_device digsy_mtc_eeprom = {
|
|
.name = "spi_gpio",
|
|
.id = EE_SPI_BUS_NUM,
|
|
.dev = {
|
|
.platform_data = &eeprom_spi_gpio_data,
|
|
},
|
|
};
|
|
|
|
static struct gpiod_lookup_table eeprom_spi_gpiod_table = {
|
|
.dev_id = "spi_gpio",
|
|
.table = {
|
|
GPIO_LOOKUP("gpio@b00", GPIO_EEPROM_CLK,
|
|
"sck", GPIO_ACTIVE_HIGH),
|
|
GPIO_LOOKUP("gpio@b00", GPIO_EEPROM_DI,
|
|
"mosi", GPIO_ACTIVE_HIGH),
|
|
GPIO_LOOKUP("gpio@b00", GPIO_EEPROM_DO,
|
|
"miso", GPIO_ACTIVE_HIGH),
|
|
GPIO_LOOKUP("gpio@b00", GPIO_EEPROM_CS,
|
|
"cs", GPIO_ACTIVE_HIGH),
|
|
{ },
|
|
},
|
|
};
|
|
|
|
static struct spi_board_info digsy_mtc_eeprom_info[] __initdata = {
|
|
{
|
|
.modalias = "93xx46",
|
|
.max_speed_hz = 1000000,
|
|
.bus_num = EE_SPI_BUS_NUM,
|
|
.chip_select = 0,
|
|
.mode = SPI_MODE_0,
|
|
.platform_data = &digsy_mtc_eeprom_data,
|
|
},
|
|
};
|
|
|
|
static int __init digsy_mtc_eeprom_devices_init(void)
|
|
{
|
|
int ret;
|
|
|
|
ret = gpio_request_one(GPIO_EEPROM_OE, GPIOF_OUT_INIT_HIGH,
|
|
"93xx46 EEPROMs OE");
|
|
if (ret) {
|
|
pr_err("can't request gpio %d\n", GPIO_EEPROM_OE);
|
|
return ret;
|
|
}
|
|
gpiod_add_lookup_table(&eeprom_spi_gpiod_table);
|
|
spi_register_board_info(digsy_mtc_eeprom_info,
|
|
ARRAY_SIZE(digsy_mtc_eeprom_info));
|
|
return platform_device_register(&digsy_mtc_eeprom);
|
|
}
|
|
device_initcall(digsy_mtc_eeprom_devices_init);
|