Skip to content

Commit

Permalink
Merge tag 'at91-drivers' of git://github.com/at91linux/linux-at91 int…
Browse files Browse the repository at this point in the history
…o next/drivers

Merge "at91: drivers for 3.17 #1" from Nicolas Ferre:

"This update delayed to 3.17, is about replacing the existing calls to the
older, non-standard drivers by the use of the newer "pwm-atmel" which takes
advantage of the PWM framework.
All concerned maintainer gave their acknowledgement to the relevant patches.
At the end, it removes three obsolete drivers and the diffstat looks pretty
nice as well."

Atmel PWM driver update for 3.17
- move to the new PWM driver which uses PWM framework
- remove 3 obsolete drivers (atmel-pwm-bl.c, leds-atmel-pwm.c and atmel_pwm.c)

* tag 'at91-drivers' of git://github.com/at91linux/linux-at91:
  misc: atmel_pwm: remove obsolete driver
  leds: atmel-pwm: remove obsolete driver
  backlight: atmel-pwm-bl: remove obsolete driver
  avr32: update defconfig to use the generic PWM framework
  avr32: favr-32: use generic pwm_bl driver
  avr32: merisc: use generic leds_pwm driver
  avr32: MRMT: use generic leds_pwm driver
  avr32/at32ap: switch to the generic PWM framework
  PWM: atmel: allow building for AVR32
  ARM: at91: remove useless at91_pwm_leds()
  ARM: at91: at91sam9rl: switch to generic PWM framework
  ARM: at91: sam9263ek: use generic leds_pwm driver
  ARM: at91: at91sam9263: switch to generic PWM framework
  ARM: at91: sam9m10g45ek: use generic leds_pwm driver
  ARM: at91: at91sam9g45: switch to generic PWM framework

Signed-off-by: Olof Johansson <[email protected]>
  • Loading branch information
olofj committed Jul 13, 2014
2 parents 4c83445 + f2a70e1 commit bde19a7
Show file tree
Hide file tree
Showing 33 changed files with 186 additions and 1,065 deletions.
1 change: 1 addition & 0 deletions arch/arm/mach-at91/at91sam9263.c
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,7 @@ static struct clk_lookup periph_clocks_lookups[] = {
CLKDEV_CON_DEV_ID("spi_clk", "atmel_spi.1", &spi1_clk),
CLKDEV_CON_DEV_ID("t0_clk", "atmel_tcb.0", &tcb_clk),
CLKDEV_CON_DEV_ID(NULL, "i2c-at91sam9260.0", &twi_clk),
CLKDEV_CON_DEV_ID(NULL, "at91sam9rl-pwm", &pwm_clk),
/* fake hclk clock */
CLKDEV_CON_DEV_ID("hclk", "at91_ohci", &ohci_clk),
CLKDEV_CON_ID("pioA", &pioA_clk),
Expand Down
11 changes: 2 additions & 9 deletions arch/arm/mach-at91/at91sam9263_devices.c
Original file line number Diff line number Diff line change
Expand Up @@ -1131,9 +1131,7 @@ static void __init at91_add_device_watchdog(void) {}
* PWM
* --------------------------------------------------------------------*/

#if defined(CONFIG_ATMEL_PWM)
static u32 pwm_mask;

#if IS_ENABLED(CONFIG_PWM_ATMEL)
static struct resource pwm_resources[] = {
[0] = {
.start = AT91SAM9263_BASE_PWMC,
Expand All @@ -1148,11 +1146,8 @@ static struct resource pwm_resources[] = {
};

static struct platform_device at91sam9263_pwm0_device = {
.name = "atmel_pwm",
.name = "at91sam9rl-pwm",
.id = -1,
.dev = {
.platform_data = &pwm_mask,
},
.resource = pwm_resources,
.num_resources = ARRAY_SIZE(pwm_resources),
};
Expand All @@ -1171,8 +1166,6 @@ void __init at91_add_device_pwm(u32 mask)
if (mask & (1 << AT91_PWM3))
at91_set_B_periph(AT91_PIN_PB29, 1); /* enable PWM3 */

pwm_mask = mask;

platform_device_register(&at91sam9263_pwm0_device);
}
#else
Expand Down
1 change: 1 addition & 0 deletions arch/arm/mach-at91/at91sam9g45.c
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,7 @@ static struct clk_lookup periph_clocks_lookups[] = {
CLKDEV_CON_DEV_ID(NULL, "atmel_sha", &aestdessha_clk),
CLKDEV_CON_DEV_ID(NULL, "atmel_tdes", &aestdessha_clk),
CLKDEV_CON_DEV_ID(NULL, "atmel_aes", &aestdessha_clk),
CLKDEV_CON_DEV_ID(NULL, "at91sam9rl-pwm", &pwm_clk),
/* more usart lookup table for DT entries */
CLKDEV_CON_DEV_ID("usart", "ffffee00.serial", &mck),
CLKDEV_CON_DEV_ID("usart", "fff8c000.serial", &usart0_clk),
Expand Down
11 changes: 2 additions & 9 deletions arch/arm/mach-at91/at91sam9g45_devices.c
Original file line number Diff line number Diff line change
Expand Up @@ -1334,9 +1334,7 @@ static void __init at91_add_device_watchdog(void) {}
* PWM
* --------------------------------------------------------------------*/

#if defined(CONFIG_ATMEL_PWM) || defined(CONFIG_ATMEL_PWM_MODULE)
static u32 pwm_mask;

#if IS_ENABLED(CONFIG_PWM_ATMEL)
static struct resource pwm_resources[] = {
[0] = {
.start = AT91SAM9G45_BASE_PWMC,
Expand All @@ -1351,11 +1349,8 @@ static struct resource pwm_resources[] = {
};

static struct platform_device at91sam9g45_pwm0_device = {
.name = "atmel_pwm",
.name = "at91sam9rl-pwm",
.id = -1,
.dev = {
.platform_data = &pwm_mask,
},
.resource = pwm_resources,
.num_resources = ARRAY_SIZE(pwm_resources),
};
Expand All @@ -1374,8 +1369,6 @@ void __init at91_add_device_pwm(u32 mask)
if (mask & (1 << AT91_PWM3))
at91_set_B_periph(AT91_PIN_PD0, 1); /* enable PWM3 */

pwm_mask = mask;

platform_device_register(&at91sam9g45_pwm0_device);
}
#else
Expand Down
1 change: 1 addition & 0 deletions arch/arm/mach-at91/at91sam9rl.c
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,7 @@ static struct clk_lookup periph_clocks_lookups[] = {
CLKDEV_CON_DEV_ID("pclk", "fffc4000.ssc", &ssc1_clk),
CLKDEV_CON_DEV_ID(NULL, "i2c-at91sam9g20.0", &twi0_clk),
CLKDEV_CON_DEV_ID(NULL, "i2c-at91sam9g20.1", &twi1_clk),
CLKDEV_CON_DEV_ID(NULL, "at91sam9rl-pwm", &pwm_clk),
CLKDEV_CON_ID("pioA", &pioA_clk),
CLKDEV_CON_ID("pioB", &pioB_clk),
CLKDEV_CON_ID("pioC", &pioC_clk),
Expand Down
11 changes: 2 additions & 9 deletions arch/arm/mach-at91/at91sam9rl_devices.c
Original file line number Diff line number Diff line change
Expand Up @@ -799,9 +799,7 @@ static void __init at91_add_device_watchdog(void) {}
* PWM
* --------------------------------------------------------------------*/

#if defined(CONFIG_ATMEL_PWM)
static u32 pwm_mask;

#if IS_ENABLED(CONFIG_PWM_ATMEL)
static struct resource pwm_resources[] = {
[0] = {
.start = AT91SAM9RL_BASE_PWMC,
Expand All @@ -816,11 +814,8 @@ static struct resource pwm_resources[] = {
};

static struct platform_device at91sam9rl_pwm0_device = {
.name = "atmel_pwm",
.name = "at91sam9rl-pwm",
.id = -1,
.dev = {
.platform_data = &pwm_mask,
},
.resource = pwm_resources,
.num_resources = ARRAY_SIZE(pwm_resources),
};
Expand All @@ -839,8 +834,6 @@ void __init at91_add_device_pwm(u32 mask)
if (mask & (1 << AT91_PWM3))
at91_set_B_periph(AT91_PIN_PD8, 1); /* enable PWM3 */

pwm_mask = mask;

platform_device_register(&at91sam9rl_pwm0_device);
}
#else
Expand Down
55 changes: 47 additions & 8 deletions arch/arm/mach-at91/board-sam9263ek.c
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@
#include <linux/gpio_keys.h>
#include <linux/input.h>
#include <linux/leds.h>
#include <linux/pwm.h>
#include <linux/leds_pwm.h>

#include <video/atmel_lcdc.h>

Expand Down Expand Up @@ -369,21 +371,47 @@ static struct gpio_led ek_leds[] = {
.name = "ds3",
.gpio = AT91_PIN_PB7,
.default_trigger = "heartbeat",
},
#if !IS_ENABLED(CONFIG_LEDS_PWM)
{
.name = "ds1",
.gpio = AT91_PIN_PB8,
.active_low = 1,
.default_trigger = "none",
}
#endif
};

/*
* PWM Leds
*/
static struct gpio_led ek_pwm_led[] = {
/* For now only DS1 is PWM-driven (by pwm1) */
static struct pwm_lookup pwm_lookup[] = {
PWM_LOOKUP("at91sam9rl-pwm", 1, "leds_pwm", "ds1",
5000, PWM_POLARITY_INVERSED),
};

#if IS_ENABLED(CONFIG_LEDS_PWM)
static struct led_pwm pwm_leds[] = {
{
.name = "ds1",
.gpio = 1, /* is PWM channel number */
.active_low = 1,
.default_trigger = "none",
}
.name = "ds1",
.max_brightness = 255,
},
};

static struct led_pwm_platform_data pwm_data = {
.num_leds = ARRAY_SIZE(pwm_leds),
.leds = pwm_leds,
};

static struct platform_device leds_pwm = {
.name = "leds_pwm",
.id = -1,
.dev = {
.platform_data = &pwm_data,
},
};
#endif


/*
* CAN
Expand All @@ -403,6 +431,12 @@ static struct at91_can_data ek_can_data = {
.transceiver_switch = sam9263ek_transceiver_switch,
};

static struct platform_device *devices[] __initdata = {
#if IS_ENABLED(CONFIG_LEDS_PWM)
&leds_pwm,
#endif
};

static void __init ek_board_init(void)
{
/* Serial */
Expand Down Expand Up @@ -437,9 +471,14 @@ static void __init ek_board_init(void)
at91_add_device_ac97(&ek_ac97_data);
/* LEDs */
at91_gpio_leds(ek_leds, ARRAY_SIZE(ek_leds));
at91_pwm_leds(ek_pwm_led, ARRAY_SIZE(ek_pwm_led));
pwm_add_table(pwm_lookup, ARRAY_SIZE(pwm_lookup));
#if IS_ENABLED(CONFIG_LEDS_PWM)
at91_add_device_pwm(1 << AT91_PWM1);
#endif
/* CAN */
at91_add_device_can(&ek_can_data);
/* Other platform devices */
platform_add_devices(devices, ARRAY_SIZE(devices));
}

MACHINE_START(AT91SAM9263EK, "Atmel AT91SAM9263-EK")
Expand Down
42 changes: 33 additions & 9 deletions arch/arm/mach-at91/board-sam9m10g45ek.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@
#include <linux/leds.h>
#include <linux/atmel-mci.h>
#include <linux/delay.h>
#include <linux/pwm.h>
#include <linux/leds_pwm.h>

#include <linux/platform_data/at91_adc.h>

Expand Down Expand Up @@ -416,7 +418,7 @@ static struct gpio_led ek_leds[] = {
.active_low = 1,
.default_trigger = "nand-disk",
},
#if !(defined(CONFIG_LEDS_ATMEL_PWM) || defined(CONFIG_LEDS_ATMEL_PWM_MODULE))
#if !IS_ENABLED(CONFIG_LEDS_PWM)
{ /* "right" led, green, userled1, pwm1 */
.name = "d7",
.gpio = AT91_PIN_PD31,
Expand All @@ -430,22 +432,41 @@ static struct gpio_led ek_leds[] = {
/*
* PWM Leds
*/
static struct gpio_led ek_pwm_led[] = {
#if defined(CONFIG_LEDS_ATMEL_PWM) || defined(CONFIG_LEDS_ATMEL_PWM_MODULE)
static struct pwm_lookup pwm_lookup[] = {
PWM_LOOKUP("at91sam9rl-pwm", 1, "leds_pwm", "d7",
5000, PWM_POLARITY_INVERSED),
};

#if IS_ENABLED(CONFIG_LEDS_PWM)
static struct led_pwm pwm_leds[] = {
{ /* "right" led, green, userled1, pwm1 */
.name = "d7",
.gpio = 1, /* is PWM channel number */
.active_low = 1,
.default_trigger = "none",
.name = "d7",
.max_brightness = 255,
},
#endif
};

static struct led_pwm_platform_data pwm_data = {
.num_leds = ARRAY_SIZE(pwm_leds),
.leds = pwm_leds,
};

static struct platform_device leds_pwm = {
.name = "leds_pwm",
.id = -1,
.dev = {
.platform_data = &pwm_data,
},
};
#endif

static struct platform_device *devices[] __initdata = {
#if defined(CONFIG_SOC_CAMERA_OV2640) || \
defined(CONFIG_SOC_CAMERA_OV2640_MODULE)
&isi_ov2640,
#endif
#if IS_ENABLED(CONFIG_LEDS_PWM)
&leds_pwm,
#endif
};

static void __init ek_board_init(void)
Expand Down Expand Up @@ -486,7 +507,10 @@ static void __init ek_board_init(void)
at91_add_device_ac97(&ek_ac97_data);
/* LEDs */
at91_gpio_leds(ek_leds, ARRAY_SIZE(ek_leds));
at91_pwm_leds(ek_pwm_led, ARRAY_SIZE(ek_pwm_led));
pwm_add_table(pwm_lookup, ARRAY_SIZE(pwm_lookup));
#if IS_ENABLED(CONFIG_LEDS_PWM)
at91_add_device_pwm(1 << AT91_PWM1);
#endif
/* Other platform devices */
platform_add_devices(devices, ARRAY_SIZE(devices));
}
Expand Down
1 change: 0 additions & 1 deletion arch/arm/mach-at91/board.h
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,5 @@ extern void __init at91_add_device_can(struct at91_can_data *data);

/* LEDs */
extern void __init at91_gpio_leds(struct gpio_led *leds, int nr);
extern void __init at91_pwm_leds(struct gpio_led *leds, int nr);

#endif
37 changes: 0 additions & 37 deletions arch/arm/mach-at91/leds.c
Original file line number Diff line number Diff line change
Expand Up @@ -54,40 +54,3 @@ void __init at91_gpio_leds(struct gpio_led *leds, int nr)
void __init at91_gpio_leds(struct gpio_led *leds, int nr) {}
#endif


/* ------------------------------------------------------------------------- */

#if defined (CONFIG_LEDS_ATMEL_PWM)

/*
* PWM Leds
*/

static struct gpio_led_platform_data pwm_led_data;

static struct platform_device at91_pwm_leds_device = {
.name = "leds-atmel-pwm",
.id = -1,
.dev.platform_data = &pwm_led_data,
};

void __init at91_pwm_leds(struct gpio_led *leds, int nr)
{
int i;
u32 pwm_mask = 0;

if (!nr)
return;

for (i = 0; i < nr; i++)
pwm_mask |= (1 << leds[i].gpio);

pwm_led_data.leds = leds;
pwm_led_data.num_leds = nr;

at91_add_device_pwm(pwm_mask);
platform_device_register(&at91_pwm_leds_device);
}
#else
void __init at91_pwm_leds(struct gpio_led *leds, int nr){}
#endif
Loading

0 comments on commit bde19a7

Please sign in to comment.