mirror of https://gitee.com/openkylin/linux.git
serial: max310x: Add devicetree support
This patch adds devicetree support for the MAX310X serial driver. Signed-off-by: Alexander Shiyan <shc_work@mail.ru> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
parent
5f529049cb
commit
58afc90977
|
@ -19,6 +19,8 @@
|
||||||
#include <linux/device.h>
|
#include <linux/device.h>
|
||||||
#include <linux/gpio.h>
|
#include <linux/gpio.h>
|
||||||
#include <linux/module.h>
|
#include <linux/module.h>
|
||||||
|
#include <linux/of.h>
|
||||||
|
#include <linux/of_device.h>
|
||||||
#include <linux/regmap.h>
|
#include <linux/regmap.h>
|
||||||
#include <linux/serial_core.h>
|
#include <linux/serial_core.h>
|
||||||
#include <linux/serial.h>
|
#include <linux/serial.h>
|
||||||
|
@ -1093,7 +1095,7 @@ static int max310x_gpio_direction_output(struct gpio_chip *chip,
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static int max310x_probe(struct device *dev, struct max310x_devtype *devtype,
|
static int max310x_probe(struct device *dev, struct max310x_devtype *devtype,
|
||||||
struct regmap *regmap, int irq)
|
struct regmap *regmap, int irq, unsigned long flags)
|
||||||
{
|
{
|
||||||
int i, ret, fmin, fmax, freq, uartclk;
|
int i, ret, fmin, fmax, freq, uartclk;
|
||||||
struct clk *clk_osc, *clk_xtal;
|
struct clk *clk_osc, *clk_xtal;
|
||||||
|
@ -1237,8 +1239,7 @@ static int max310x_probe(struct device *dev, struct max310x_devtype *devtype,
|
||||||
|
|
||||||
/* Setup interrupt */
|
/* Setup interrupt */
|
||||||
ret = devm_request_threaded_irq(dev, irq, NULL, max310x_ist,
|
ret = devm_request_threaded_irq(dev, irq, NULL, max310x_ist,
|
||||||
IRQF_TRIGGER_FALLING | IRQF_ONESHOT,
|
IRQF_ONESHOT | flags, dev_name(dev), s);
|
||||||
dev_name(dev), s);
|
|
||||||
if (!ret)
|
if (!ret)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
|
@ -1284,6 +1285,15 @@ static int max310x_remove(struct device *dev)
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static const struct of_device_id __maybe_unused max310x_dt_ids[] = {
|
||||||
|
{ .compatible = "maxim,max3107", .data = &max3107_devtype, },
|
||||||
|
{ .compatible = "maxim,max3108", .data = &max3108_devtype, },
|
||||||
|
{ .compatible = "maxim,max3109", .data = &max3109_devtype, },
|
||||||
|
{ .compatible = "maxim,max14830", .data = &max14830_devtype },
|
||||||
|
{ }
|
||||||
|
};
|
||||||
|
MODULE_DEVICE_TABLE(of, max310x_dt_ids);
|
||||||
|
|
||||||
static struct regmap_config regcfg = {
|
static struct regmap_config regcfg = {
|
||||||
.reg_bits = 8,
|
.reg_bits = 8,
|
||||||
.val_bits = 8,
|
.val_bits = 8,
|
||||||
|
@ -1297,8 +1307,8 @@ static struct regmap_config regcfg = {
|
||||||
#ifdef CONFIG_SPI_MASTER
|
#ifdef CONFIG_SPI_MASTER
|
||||||
static int max310x_spi_probe(struct spi_device *spi)
|
static int max310x_spi_probe(struct spi_device *spi)
|
||||||
{
|
{
|
||||||
struct max310x_devtype *devtype =
|
struct max310x_devtype *devtype;
|
||||||
(struct max310x_devtype *)spi_get_device_id(spi)->driver_data;
|
unsigned long flags = 0;
|
||||||
struct regmap *regmap;
|
struct regmap *regmap;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
|
@ -1310,10 +1320,22 @@ static int max310x_spi_probe(struct spi_device *spi)
|
||||||
if (ret)
|
if (ret)
|
||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
|
if (spi->dev.of_node) {
|
||||||
|
const struct of_device_id *of_id =
|
||||||
|
of_match_device(max310x_dt_ids, &spi->dev);
|
||||||
|
|
||||||
|
devtype = (struct max310x_devtype *)of_id->data;
|
||||||
|
} else {
|
||||||
|
const struct spi_device_id *id_entry = spi_get_device_id(spi);
|
||||||
|
|
||||||
|
devtype = (struct max310x_devtype *)id_entry->driver_data;
|
||||||
|
flags = IRQF_TRIGGER_FALLING;
|
||||||
|
}
|
||||||
|
|
||||||
regcfg.max_register = devtype->nr * 0x20 - 1;
|
regcfg.max_register = devtype->nr * 0x20 - 1;
|
||||||
regmap = devm_regmap_init_spi(spi, ®cfg);
|
regmap = devm_regmap_init_spi(spi, ®cfg);
|
||||||
|
|
||||||
return max310x_probe(&spi->dev, devtype, regmap, spi->irq);
|
return max310x_probe(&spi->dev, devtype, regmap, spi->irq, flags);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int max310x_spi_remove(struct spi_device *spi)
|
static int max310x_spi_remove(struct spi_device *spi)
|
||||||
|
@ -1332,9 +1354,10 @@ MODULE_DEVICE_TABLE(spi, max310x_id_table);
|
||||||
|
|
||||||
static struct spi_driver max310x_uart_driver = {
|
static struct spi_driver max310x_uart_driver = {
|
||||||
.driver = {
|
.driver = {
|
||||||
.name = MAX310X_NAME,
|
.name = MAX310X_NAME,
|
||||||
.owner = THIS_MODULE,
|
.owner = THIS_MODULE,
|
||||||
.pm = &max310x_pm_ops,
|
.of_match_table = of_match_ptr(max310x_dt_ids),
|
||||||
|
.pm = &max310x_pm_ops,
|
||||||
},
|
},
|
||||||
.probe = max310x_spi_probe,
|
.probe = max310x_spi_probe,
|
||||||
.remove = max310x_spi_remove,
|
.remove = max310x_spi_remove,
|
||||||
|
|
Loading…
Reference in New Issue