mirror of
https://github.com/torvalds/linux.git
synced 2026-07-27 17:47:41 +02:00
p54spi: convert to devicetree
The Prism54 SPI driver hardcodes GPIO numbers and expects users to pass them as module parameters, apparently a relic from its life as a staging driver. This works because there is only one user, the Nokia N8x0 tablet. Convert this to the gpio descriptor interface and DT based probing to improve this and simplify the code at the same time. Acked-by: Christian Lamparter <chunkeey@gmail.com> Reviewed-by: Linus Walleij <linusw@kernel.org> Signed-off-by: Arnd Bergmann <arnd@arndb.de> Reviewed-by: Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com> Link: https://patch.msgid.link/20260507212451.3333185-3-arnd@kernel.org Signed-off-by: Johannes Berg <johannes.berg@intel.com>
This commit is contained in:
parent
16fd6b653c
commit
2f3592c92b
|
|
@ -20,7 +20,6 @@
|
|||
#include <linux/spi/spi.h>
|
||||
#include <linux/usb/musb.h>
|
||||
#include <linux/mmc/host.h>
|
||||
#include <linux/platform_data/spi-omap2-mcspi.h>
|
||||
#include <linux/platform_data/mmc-omap.h>
|
||||
#include <linux/mfd/menelaus.h>
|
||||
|
||||
|
|
@ -106,21 +105,6 @@ static void __init n8x0_usb_init(void) {}
|
|||
|
||||
#endif /*CONFIG_USB_MUSB_TUSB6010 */
|
||||
|
||||
|
||||
static struct omap2_mcspi_device_config p54spi_mcspi_config = {
|
||||
.turbo_mode = 0,
|
||||
};
|
||||
|
||||
static struct spi_board_info n800_spi_board_info[] __initdata = {
|
||||
{
|
||||
.modalias = "p54spi",
|
||||
.bus_num = 2,
|
||||
.chip_select = 0,
|
||||
.max_speed_hz = 48000000,
|
||||
.controller_data = &p54spi_mcspi_config,
|
||||
},
|
||||
};
|
||||
|
||||
#if defined(CONFIG_MENELAUS) && IS_ENABLED(CONFIG_MMC_OMAP)
|
||||
|
||||
/*
|
||||
|
|
@ -524,7 +508,5 @@ omap_late_initcall(n8x0_late_initcall);
|
|||
void * __init n8x0_legacy_init(void)
|
||||
{
|
||||
board_check_revision();
|
||||
spi_register_board_info(n800_spi_board_info,
|
||||
ARRAY_SIZE(n800_spi_board_info));
|
||||
return &mmc1_data;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,6 +8,7 @@
|
|||
*/
|
||||
|
||||
#include <linux/module.h>
|
||||
#include <linux/mod_devicetable.h>
|
||||
#include <linux/platform_device.h>
|
||||
#include <linux/interrupt.h>
|
||||
#include <linux/firmware.h>
|
||||
|
|
@ -15,7 +16,7 @@
|
|||
#include <linux/irq.h>
|
||||
#include <linux/spi/spi.h>
|
||||
#include <linux/etherdevice.h>
|
||||
#include <linux/gpio.h>
|
||||
#include <linux/gpio/consumer.h>
|
||||
#include <linux/slab.h>
|
||||
|
||||
#include "p54spi.h"
|
||||
|
|
@ -30,19 +31,6 @@
|
|||
MODULE_FIRMWARE("3826.arm");
|
||||
MODULE_FIRMWARE("3826.eeprom");
|
||||
|
||||
/* gpios should be handled in board files and provided via platform data,
|
||||
* but because it's currently impossible for p54spi to have a header file
|
||||
* in include/linux, let's use module parameters for now
|
||||
*/
|
||||
|
||||
static int p54spi_gpio_power = 97;
|
||||
module_param(p54spi_gpio_power, int, 0444);
|
||||
MODULE_PARM_DESC(p54spi_gpio_power, "gpio number for power line");
|
||||
|
||||
static int p54spi_gpio_irq = 87;
|
||||
module_param(p54spi_gpio_irq, int, 0444);
|
||||
MODULE_PARM_DESC(p54spi_gpio_irq, "gpio number for irq line");
|
||||
|
||||
static void p54spi_spi_read(struct p54s_priv *priv, u8 address,
|
||||
void *buf, size_t len)
|
||||
{
|
||||
|
|
@ -262,14 +250,14 @@ static int p54spi_upload_firmware(struct ieee80211_hw *dev)
|
|||
|
||||
static void p54spi_power_off(struct p54s_priv *priv)
|
||||
{
|
||||
disable_irq(gpio_to_irq(p54spi_gpio_irq));
|
||||
gpio_set_value(p54spi_gpio_power, 0);
|
||||
disable_irq(priv->irq);
|
||||
gpiod_set_value(priv->gpio_powerdown, 1);
|
||||
}
|
||||
|
||||
static void p54spi_power_on(struct p54s_priv *priv)
|
||||
{
|
||||
gpio_set_value(p54spi_gpio_power, 1);
|
||||
enable_irq(gpio_to_irq(p54spi_gpio_irq));
|
||||
gpiod_set_value(priv->gpio_powerdown, 0);
|
||||
enable_irq(priv->irq);
|
||||
|
||||
/* need to wait a while before device can be accessed, the length
|
||||
* is just a guess
|
||||
|
|
@ -608,31 +596,20 @@ static int p54spi_probe(struct spi_device *spi)
|
|||
goto err_free;
|
||||
}
|
||||
|
||||
ret = gpio_request(p54spi_gpio_power, "p54spi power");
|
||||
if (ret < 0) {
|
||||
dev_err(&priv->spi->dev, "power GPIO request failed: %d", ret);
|
||||
priv->gpio_powerdown = gpiod_get_optional(&spi->dev, "powerdown", GPIOD_OUT_HIGH);
|
||||
if (IS_ERR(priv->gpio_powerdown)) {
|
||||
ret = dev_err_probe(&priv->spi->dev, PTR_ERR(priv->gpio_powerdown),
|
||||
"powerdown GPIO request failed\n");
|
||||
goto err_free;
|
||||
}
|
||||
|
||||
ret = gpio_request(p54spi_gpio_irq, "p54spi irq");
|
||||
ret = request_irq(spi->irq, p54spi_interrupt, IRQF_NO_AUTOEN, "p54spi", priv->spi);
|
||||
if (ret < 0) {
|
||||
dev_err(&priv->spi->dev, "irq GPIO request failed: %d", ret);
|
||||
dev_err(&priv->spi->dev, "request_irq() failed");
|
||||
goto err_free_gpio_power;
|
||||
}
|
||||
|
||||
gpio_direction_output(p54spi_gpio_power, 0);
|
||||
gpio_direction_input(p54spi_gpio_irq);
|
||||
|
||||
ret = request_irq(gpio_to_irq(p54spi_gpio_irq),
|
||||
p54spi_interrupt, IRQF_NO_AUTOEN, "p54spi",
|
||||
priv->spi);
|
||||
if (ret < 0) {
|
||||
dev_err(&priv->spi->dev, "request_irq() failed");
|
||||
goto err_free_gpio_irq;
|
||||
}
|
||||
|
||||
irq_set_irq_type(gpio_to_irq(p54spi_gpio_irq), IRQ_TYPE_EDGE_RISING);
|
||||
|
||||
priv->irq = spi->irq;
|
||||
INIT_WORK(&priv->work, p54spi_work);
|
||||
init_completion(&priv->fw_comp);
|
||||
INIT_LIST_HEAD(&priv->tx_pending);
|
||||
|
|
@ -659,11 +636,9 @@ static int p54spi_probe(struct spi_device *spi)
|
|||
|
||||
err_free_common:
|
||||
release_firmware(priv->firmware);
|
||||
free_irq(gpio_to_irq(p54spi_gpio_irq), spi);
|
||||
err_free_gpio_irq:
|
||||
gpio_free(p54spi_gpio_irq);
|
||||
free_irq(priv->irq, spi);
|
||||
err_free_gpio_power:
|
||||
gpio_free(p54spi_gpio_power);
|
||||
gpiod_put(priv->gpio_powerdown);
|
||||
err_free:
|
||||
p54_free_common(priv->hw);
|
||||
return ret;
|
||||
|
|
@ -675,10 +650,8 @@ static void p54spi_remove(struct spi_device *spi)
|
|||
|
||||
p54_unregister_common(priv->hw);
|
||||
|
||||
free_irq(gpio_to_irq(p54spi_gpio_irq), spi);
|
||||
|
||||
gpio_free(p54spi_gpio_power);
|
||||
gpio_free(p54spi_gpio_irq);
|
||||
free_irq(priv->irq, spi);
|
||||
gpiod_put(priv->gpio_powerdown);
|
||||
release_firmware(priv->firmware);
|
||||
|
||||
mutex_destroy(&priv->mutex);
|
||||
|
|
@ -686,10 +659,16 @@ static void p54spi_remove(struct spi_device *spi)
|
|||
p54_free_common(priv->hw);
|
||||
}
|
||||
|
||||
static const struct of_device_id p54spi_of_ids[] = {
|
||||
{ .compatible = "st,stlc4560", },
|
||||
{ },
|
||||
};
|
||||
MODULE_DEVICE_TABLE(of, p54spi_of_ids);
|
||||
|
||||
static struct spi_driver p54spi_driver = {
|
||||
.driver = {
|
||||
.name = "p54spi",
|
||||
.of_match_table = p54spi_of_ids,
|
||||
},
|
||||
|
||||
.probe = p54spi_probe,
|
||||
|
|
|
|||
|
|
@ -107,6 +107,9 @@ struct p54s_priv {
|
|||
|
||||
enum fw_state fw_state;
|
||||
const struct firmware *firmware;
|
||||
|
||||
struct gpio_desc *gpio_powerdown;
|
||||
int irq;
|
||||
};
|
||||
|
||||
#endif /* P54SPI_H */
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user