Commit 50ec8812 authored by Andy Shevchenko's avatar Andy Shevchenko Committed by Marc Kleine-Budde

can: mcp251x: get rid of legacy platform data

Instead of using legacy platform data, switch to use device properties.
For clock frequency we are using well established clock-frequency property.

Users, two for now, are also converted here.

Cc: Daniel Mack <daniel@zonque.org>
Cc: Haojian Zhuang <haojian.zhuang@gmail.com>
Cc: Robert Jarzmik <robert.jarzmik@free.fr>
Cc: Russell King <linux@armlinux.org.uk>
Signed-off-by: default avatarAndy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: default avatarMarc Kleine-Budde <mkl@pengutronix.de>
parent 371fd7ba
...@@ -12,6 +12,7 @@ ...@@ -12,6 +12,7 @@
#include <linux/irq.h> #include <linux/irq.h>
#include <linux/platform_device.h> #include <linux/platform_device.h>
#include <linux/property.h>
#include <linux/gpio.h> #include <linux/gpio.h>
#include <asm/mach-types.h> #include <asm/mach-types.h>
...@@ -22,7 +23,6 @@ ...@@ -22,7 +23,6 @@
#include <linux/spi/spi.h> #include <linux/spi/spi.h>
#include <linux/spi/pxa2xx_spi.h> #include <linux/spi/pxa2xx_spi.h>
#include <linux/can/platform/mcp251x.h>
#include <linux/regulator/machine.h> #include <linux/regulator/machine.h>
#include "generic.h" #include "generic.h"
...@@ -69,8 +69,9 @@ static struct pxa2xx_spi_chip mcp251x_chip_info4 = { ...@@ -69,8 +69,9 @@ static struct pxa2xx_spi_chip mcp251x_chip_info4 = {
.gpio_cs = ICONTROL_MCP251x_nCS4 .gpio_cs = ICONTROL_MCP251x_nCS4
}; };
static struct mcp251x_platform_data mcp251x_info = { static const struct property_entry mcp251x_properties[] = {
.oscillator_frequency = 16E6, PROPERTY_ENTRY_U32("clock-frequency", 16000000),
{}
}; };
static struct spi_board_info mcp251x_board_info[] = { static struct spi_board_info mcp251x_board_info[] = {
...@@ -79,7 +80,7 @@ static struct spi_board_info mcp251x_board_info[] = { ...@@ -79,7 +80,7 @@ static struct spi_board_info mcp251x_board_info[] = {
.max_speed_hz = 6500000, .max_speed_hz = 6500000,
.bus_num = 3, .bus_num = 3,
.chip_select = 0, .chip_select = 0,
.platform_data = &mcp251x_info, .properties = mcp251x_properties,
.controller_data = &mcp251x_chip_info1, .controller_data = &mcp251x_chip_info1,
.irq = PXA_GPIO_TO_IRQ(ICONTROL_MCP251x_nIRQ1) .irq = PXA_GPIO_TO_IRQ(ICONTROL_MCP251x_nIRQ1)
}, },
......
...@@ -13,6 +13,7 @@ ...@@ -13,6 +13,7 @@
#include <linux/leds.h> #include <linux/leds.h>
#include <linux/irq.h> #include <linux/irq.h>
#include <linux/pm.h> #include <linux/pm.h>
#include <linux/property.h>
#include <linux/gpio.h> #include <linux/gpio.h>
#include <linux/gpio/machine.h> #include <linux/gpio/machine.h>
#include <linux/serial_8250.h> #include <linux/serial_8250.h>
...@@ -27,7 +28,6 @@ ...@@ -27,7 +28,6 @@
#include <linux/platform_data/i2c-pxa.h> #include <linux/platform_data/i2c-pxa.h>
#include <linux/platform_data/pca953x.h> #include <linux/platform_data/pca953x.h>
#include <linux/apm-emulation.h> #include <linux/apm-emulation.h>
#include <linux/can/platform/mcp251x.h>
#include <linux/regulator/fixed.h> #include <linux/regulator/fixed.h>
#include <linux/regulator/machine.h> #include <linux/regulator/machine.h>
...@@ -428,14 +428,15 @@ static struct gpiod_lookup_table can_regulator_gpiod_table = { ...@@ -428,14 +428,15 @@ static struct gpiod_lookup_table can_regulator_gpiod_table = {
}, },
}; };
static struct mcp251x_platform_data zeus_mcp2515_pdata = { static const struct property_entry mcp251x_properties[] = {
.oscillator_frequency = 16*1000*1000, PROPERTY_ENTRY_U32("clock-frequency", 16000000),
{}
}; };
static struct spi_board_info zeus_spi_board_info[] = { static struct spi_board_info zeus_spi_board_info[] = {
[0] = { [0] = {
.modalias = "mcp2515", .modalias = "mcp2515",
.platform_data = &zeus_mcp2515_pdata, .properties = mcp251x_properties,
.irq = PXA_GPIO_TO_IRQ(ZEUS_CAN_GPIO), .irq = PXA_GPIO_TO_IRQ(ZEUS_CAN_GPIO),
.max_speed_hz = 1*1000*1000, .max_speed_hz = 1*1000*1000,
.bus_num = 3, .bus_num = 3,
......
...@@ -22,7 +22,6 @@ ...@@ -22,7 +22,6 @@
#include <linux/can/core.h> #include <linux/can/core.h>
#include <linux/can/dev.h> #include <linux/can/dev.h>
#include <linux/can/led.h> #include <linux/can/led.h>
#include <linux/can/platform/mcp251x.h>
#include <linux/clk.h> #include <linux/clk.h>
#include <linux/completion.h> #include <linux/completion.h>
#include <linux/delay.h> #include <linux/delay.h>
...@@ -986,19 +985,19 @@ MODULE_DEVICE_TABLE(spi, mcp251x_id_table); ...@@ -986,19 +985,19 @@ MODULE_DEVICE_TABLE(spi, mcp251x_id_table);
static int mcp251x_can_probe(struct spi_device *spi) static int mcp251x_can_probe(struct spi_device *spi)
{ {
const void *match = device_get_match_data(&spi->dev); const void *match = device_get_match_data(&spi->dev);
struct mcp251x_platform_data *pdata = dev_get_platdata(&spi->dev);
struct net_device *net; struct net_device *net;
struct mcp251x_priv *priv; struct mcp251x_priv *priv;
struct clk *clk; struct clk *clk;
int freq, ret; u32 freq;
int ret;
clk = devm_clk_get_optional(&spi->dev, NULL); clk = devm_clk_get_optional(&spi->dev, NULL);
if (IS_ERR(clk)) if (IS_ERR(clk))
return PTR_ERR(clk); return PTR_ERR(clk);
freq = clk_get_rate(clk); freq = clk_get_rate(clk);
if (freq == 0 && pdata) if (freq == 0)
freq = pdata->oscillator_frequency; device_property_read_u32(&spi->dev, "clock-frequency", &freq);
/* Sanity check */ /* Sanity check */
if (freq < 1000000 || freq > 25000000) if (freq < 1000000 || freq > 25000000)
......
/* SPDX-License-Identifier: GPL-2.0 */
#ifndef _CAN_PLATFORM_MCP251X_H
#define _CAN_PLATFORM_MCP251X_H
/*
*
* CAN bus driver for Microchip 251x CAN Controller with SPI Interface
*
*/
#include <linux/spi/spi.h>
/*
* struct mcp251x_platform_data - MCP251X SPI CAN controller platform data
* @oscillator_frequency: - oscillator frequency in Hz
*/
struct mcp251x_platform_data {
unsigned long oscillator_frequency;
};
#endif /* !_CAN_PLATFORM_MCP251X_H */
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment