[PATCH 10/16] avr32: MRMT: use generic leds_pwm driver

2014-03-19 Thread Alexandre Belloni
Switch to the generic leds_pwm driver instead of leds-atmel-pwm.

Signed-off-by: Alexandre Belloni alexandre.bell...@free-electrons.com
---
 arch/avr32/boards/atngw100/mrmt.c | 35 +++
 1 file changed, 23 insertions(+), 12 deletions(-)

diff --git a/arch/avr32/boards/atngw100/mrmt.c 
b/arch/avr32/boards/atngw100/mrmt.c
index 1ba09e4c02b1..134e94c3d504 100644
--- a/arch/avr32/boards/atngw100/mrmt.c
+++ b/arch/avr32/boards/atngw100/mrmt.c
@@ -17,6 +17,8 @@
 #include linux/types.h
 #include linux/fb.h
 #include linux/leds.h
+#include linux/pwm.h
+#include linux/leds_pwm.h
 #include linux/input.h
 #include linux/gpio_keys.h
 #include linux/atmel_serial.h
@@ -155,21 +157,29 @@ static struct platform_device rmt_ts_device = {
 
 #ifdef CONFIG_BOARD_MRMT_BL_PWM
 /* PWM LEDs: LCD Backlight, etc */
-static struct gpio_led rmt_pwm_led[] = {
-   /* here the gpio is actually a PWM channel */
-   { .name = backlight,  .gpio = PWM_CH_BL, },
+static struct pwm_lookup pwm_lookup[] = {
+   PWM_LOOKUP(at91sam9rl-pwm, PWM_CH_BL, leds_pwm, ds1),
 };
 
-static struct gpio_led_platform_data rmt_pwm_led_data = {
-   .num_leds   = ARRAY_SIZE(rmt_pwm_led),
-   .leds   = rmt_pwm_led,
+static struct led_pwm pwm_leds[] = {
+   {
+   .name = backlight,
+   .max_brightness = 255,
+   .pwm_period_ns  = 5000,
+   .active_low = 1,
+   },
+};
+
+static struct led_pwm_platform_data pwm_data = {
+   .num_leds   = ARRAY_SIZE(pwm_leds),
+   .leds   = pwm_leds,
 };
 
-static struct platform_device rmt_pwm_led_dev = {
-   .name   = leds-atmel-pwm,
-   .id = -1,
-   .dev= {
-   .platform_data  = rmt_pwm_led_data,
+static struct platform_device leds_pwm = {
+   .name   = leds_pwm,
+   .id = -1,
+   .dev= {
+   .platform_data = pwm_data,
},
 };
 #endif
@@ -325,7 +335,8 @@ static int __init mrmt1_init(void)
 #ifdef CONFIG_BOARD_MRMT_BL_PWM
/* Use PWM for Backlight controls */
at32_add_device_pwm(1  PWM_CH_BL);
-   platform_device_register(rmt_pwm_led_dev);
+   pwm_add_table(pwm_lookup, ARRAY_SIZE(pwm_lookup));
+   platform_device_register(leds_pwm);
 #else
/* Backlight always on */
udelay( 1 );
-- 
1.8.3.2

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 13/16] avr32: update defconfig to use the generic PWM framework

2014-03-19 Thread Alexandre Belloni
Now that all boards have switch to the generic PWM framework, update the
defconfigs to use it.

Signed-off-by: Alexandre Belloni alexandre.bell...@free-electrons.com
---
 arch/avr32/configs/atngw100_mrmt_defconfig | 5 +++--
 arch/avr32/configs/atstk1002_defconfig | 5 +++--
 arch/avr32/configs/atstk1003_defconfig | 5 +++--
 arch/avr32/configs/atstk1004_defconfig | 5 +++--
 arch/avr32/configs/atstk1006_defconfig | 5 +++--
 arch/avr32/configs/merisc_defconfig| 5 +++--
 6 files changed, 18 insertions(+), 12 deletions(-)

diff --git a/arch/avr32/configs/atngw100_mrmt_defconfig 
b/arch/avr32/configs/atngw100_mrmt_defconfig
index 9a57da44eb6f..6838781e966f 100644
--- a/arch/avr32/configs/atngw100_mrmt_defconfig
+++ b/arch/avr32/configs/atngw100_mrmt_defconfig
@@ -56,7 +56,6 @@ CONFIG_MTD_CFI_AMDSTD=y
 CONFIG_MTD_PHYSMAP=y
 CONFIG_MTD_DATAFLASH=y
 CONFIG_BLK_DEV_LOOP=y
-CONFIG_ATMEL_PWM=y
 CONFIG_NETDEVICES=y
 CONFIG_NET_ETHERNET=y
 CONFIG_MACB=y
@@ -104,8 +103,8 @@ CONFIG_MMC=y
 CONFIG_MMC_ATMELMCI=y
 CONFIG_NEW_LEDS=y
 CONFIG_LEDS_CLASS=y
-CONFIG_LEDS_ATMEL_PWM=y
 CONFIG_LEDS_GPIO=y
+CONFIG_LEDS_PWM=y
 CONFIG_LEDS_TRIGGERS=y
 CONFIG_LEDS_TRIGGER_TIMER=y
 CONFIG_LEDS_TRIGGER_HEARTBEAT=y
@@ -114,6 +113,8 @@ CONFIG_RTC_DRV_S35390A=m
 CONFIG_RTC_DRV_AT32AP700X=m
 CONFIG_DMADEVICES=y
 CONFIG_UIO=y
+CONFIG_PWM=y
+CONFIG_PWM_ATMEL=y
 CONFIG_EXT2_FS=y
 CONFIG_EXT2_FS_XATTR=y
 CONFIG_EXT3_FS=y
diff --git a/arch/avr32/configs/atstk1002_defconfig 
b/arch/avr32/configs/atstk1002_defconfig
index 2813dd2b9138..b056820eef33 100644
--- a/arch/avr32/configs/atstk1002_defconfig
+++ b/arch/avr32/configs/atstk1002_defconfig
@@ -64,7 +64,6 @@ CONFIG_BLK_DEV_LOOP=m
 CONFIG_BLK_DEV_NBD=m
 CONFIG_BLK_DEV_RAM=m
 CONFIG_MISC_DEVICES=y
-CONFIG_ATMEL_PWM=m
 CONFIG_ATMEL_TCLIB=y
 CONFIG_ATMEL_SSC=m
 # CONFIG_SCSI_PROC_FS is not set
@@ -133,14 +132,16 @@ CONFIG_MMC_TEST=m
 CONFIG_MMC_ATMELMCI=y
 CONFIG_NEW_LEDS=y
 CONFIG_LEDS_CLASS=y
-CONFIG_LEDS_ATMEL_PWM=m
 CONFIG_LEDS_GPIO=m
+CONFIG_LEDS_PWM=m
 CONFIG_LEDS_TRIGGERS=y
 CONFIG_LEDS_TRIGGER_TIMER=m
 CONFIG_LEDS_TRIGGER_HEARTBEAT=m
 CONFIG_RTC_CLASS=y
 CONFIG_RTC_DRV_AT32AP700X=y
 CONFIG_DMADEVICES=y
+CONFIG_PWM=y
+CONFIG_PWM_ATMEL=m
 CONFIG_EXT2_FS=y
 CONFIG_EXT3_FS=y
 # CONFIG_EXT3_DEFAULTS_TO_ORDERED is not set
diff --git a/arch/avr32/configs/atstk1003_defconfig 
b/arch/avr32/configs/atstk1003_defconfig
index f8ff3a3baad4..0cd23a303da1 100644
--- a/arch/avr32/configs/atstk1003_defconfig
+++ b/arch/avr32/configs/atstk1003_defconfig
@@ -53,7 +53,6 @@ CONFIG_BLK_DEV_LOOP=m
 CONFIG_BLK_DEV_NBD=m
 CONFIG_BLK_DEV_RAM=m
 CONFIG_MISC_DEVICES=y
-CONFIG_ATMEL_PWM=m
 CONFIG_ATMEL_TCLIB=y
 CONFIG_ATMEL_SSC=m
 # CONFIG_SCSI_PROC_FS is not set
@@ -112,14 +111,16 @@ CONFIG_MMC_TEST=m
 CONFIG_MMC_ATMELMCI=y
 CONFIG_NEW_LEDS=y
 CONFIG_LEDS_CLASS=y
-CONFIG_LEDS_ATMEL_PWM=m
 CONFIG_LEDS_GPIO=m
+CONFIG_LEDS_PWM=m
 CONFIG_LEDS_TRIGGERS=y
 CONFIG_LEDS_TRIGGER_TIMER=m
 CONFIG_LEDS_TRIGGER_HEARTBEAT=m
 CONFIG_RTC_CLASS=y
 CONFIG_RTC_DRV_AT32AP700X=y
 CONFIG_DMADEVICES=y
+CONFIG_PWM=y
+CONFIG_PWM_ATMEL=m
 CONFIG_EXT2_FS=y
 CONFIG_EXT3_FS=y
 # CONFIG_EXT3_DEFAULTS_TO_ORDERED is not set
diff --git a/arch/avr32/configs/atstk1004_defconfig 
b/arch/avr32/configs/atstk1004_defconfig
index 992228e54e38..ac1041f5f85a 100644
--- a/arch/avr32/configs/atstk1004_defconfig
+++ b/arch/avr32/configs/atstk1004_defconfig
@@ -53,7 +53,6 @@ CONFIG_BLK_DEV_LOOP=m
 CONFIG_BLK_DEV_NBD=m
 CONFIG_BLK_DEV_RAM=m
 CONFIG_MISC_DEVICES=y
-CONFIG_ATMEL_PWM=m
 CONFIG_ATMEL_TCLIB=y
 CONFIG_ATMEL_SSC=m
 # CONFIG_SCSI_PROC_FS is not set
@@ -111,14 +110,16 @@ CONFIG_MMC_TEST=m
 CONFIG_MMC_ATMELMCI=y
 CONFIG_NEW_LEDS=y
 CONFIG_LEDS_CLASS=y
-CONFIG_LEDS_ATMEL_PWM=m
 CONFIG_LEDS_GPIO=m
+CONFIG_LEDS_PWM=m
 CONFIG_LEDS_TRIGGERS=y
 CONFIG_LEDS_TRIGGER_TIMER=m
 CONFIG_LEDS_TRIGGER_HEARTBEAT=m
 CONFIG_RTC_CLASS=y
 CONFIG_RTC_DRV_AT32AP700X=y
 CONFIG_DMADEVICES=y
+CONFIG_PWM=y
+CONFIG_PWM_ATMEL=m
 CONFIG_EXT2_FS=y
 CONFIG_EXT3_FS=y
 # CONFIG_EXT3_DEFAULTS_TO_ORDERED is not set
diff --git a/arch/avr32/configs/atstk1006_defconfig 
b/arch/avr32/configs/atstk1006_defconfig
index b8e698b0d1fa..ea4f670cb995 100644
--- a/arch/avr32/configs/atstk1006_defconfig
+++ b/arch/avr32/configs/atstk1006_defconfig
@@ -67,7 +67,6 @@ CONFIG_BLK_DEV_LOOP=m
 CONFIG_BLK_DEV_NBD=m
 CONFIG_BLK_DEV_RAM=m
 CONFIG_MISC_DEVICES=y
-CONFIG_ATMEL_PWM=m
 CONFIG_ATMEL_TCLIB=y
 CONFIG_ATMEL_SSC=m
 # CONFIG_SCSI_PROC_FS is not set
@@ -136,14 +135,16 @@ CONFIG_MMC_TEST=m
 CONFIG_MMC_ATMELMCI=y
 CONFIG_NEW_LEDS=y
 CONFIG_LEDS_CLASS=y
-CONFIG_LEDS_ATMEL_PWM=m
 CONFIG_LEDS_GPIO=m
+CONFIG_LEDS_PWM=m
 CONFIG_LEDS_TRIGGERS=y
 CONFIG_LEDS_TRIGGER_TIMER=m
 CONFIG_LEDS_TRIGGER_HEARTBEAT=m
 CONFIG_RTC_CLASS=y
 CONFIG_RTC_DRV_AT32AP700X=y
 CONFIG_DMADEVICES=y
+CONFIG_PWM=y
+CONFIG_PWM_ATMEL=m
 CONFIG_EXT2_FS=y
 CONFIG_EXT3_FS=y
 # CONFIG_EXT3_DEFAULTS_TO_ORDERED is not set
diff --git a/arch/avr32/configs/merisc_defconfig 
b/arch/avr32/configs/merisc_defconfig
index 91df6b2986be

[PATCH 14/16] backlight: atmel-pwm-bl: remove obsolete driver

2014-03-19 Thread Alexandre Belloni
The atmel-pwm-bl driver is now obsolete. It is not used by any mainlined boards
and is replaced by the generic pwm_bl with the pawm-atmel driver using the
generic PWM framework.

Signed-off-by: Alexandre Belloni alexandre.bell...@free-electrons.com
---
 drivers/video/backlight/Kconfig|  11 --
 drivers/video/backlight/Makefile   |   1 -
 drivers/video/backlight/atmel-pwm-bl.c | 223 -
 include/linux/atmel-pwm-bl.h   |  43 ---
 4 files changed, 278 deletions(-)
 delete mode 100644 drivers/video/backlight/atmel-pwm-bl.c
 delete mode 100644 include/linux/atmel-pwm-bl.h

diff --git a/drivers/video/backlight/Kconfig b/drivers/video/backlight/Kconfig
index 5a3eb2ecb525..9bd32b7a7561 100644
--- a/drivers/video/backlight/Kconfig
+++ b/drivers/video/backlight/Kconfig
@@ -178,17 +178,6 @@ config BACKLIGHT_ATMEL_LCDC
  If in doubt, it's safe to enable this option; it doesn't kick
  in unless the board's description says it's wired that way.
 
-config BACKLIGHT_ATMEL_PWM
-   tristate Atmel PWM backlight control
-   depends on ATMEL_PWM
-   help
- Say Y here if you want to use the PWM peripheral in Atmel AT91 and
- AVR32 devices. This driver will need additional platform data to know
- which PWM instance to use and how to configure it.
-
- To compile this driver as a module, choose M here: the module will be
- called atmel-pwm-bl.
-
 config BACKLIGHT_EP93XX
tristate Cirrus EP93xx Backlight Driver
depends on FB_EP93XX
diff --git a/drivers/video/backlight/Makefile b/drivers/video/backlight/Makefile
index bb820024f346..351451dbb607 100644
--- a/drivers/video/backlight/Makefile
+++ b/drivers/video/backlight/Makefile
@@ -25,7 +25,6 @@ obj-$(CONFIG_BACKLIGHT_ADP8860)   += adp8860_bl.o
 obj-$(CONFIG_BACKLIGHT_ADP8870)+= adp8870_bl.o
 obj-$(CONFIG_BACKLIGHT_APPLE)  += apple_bl.o
 obj-$(CONFIG_BACKLIGHT_AS3711) += as3711_bl.o
-obj-$(CONFIG_BACKLIGHT_ATMEL_PWM)  += atmel-pwm-bl.o
 obj-$(CONFIG_BACKLIGHT_BD6107) += bd6107.o
 obj-$(CONFIG_BACKLIGHT_CARILLO_RANCH)  += cr_bllcd.o
 obj-$(CONFIG_BACKLIGHT_CLASS_DEVICE)   += backlight.o
diff --git a/drivers/video/backlight/atmel-pwm-bl.c 
b/drivers/video/backlight/atmel-pwm-bl.c
deleted file mode 100644
index 261b1a4ec3d8..
--- a/drivers/video/backlight/atmel-pwm-bl.c
+++ /dev/null
@@ -1,223 +0,0 @@
-/*
- * Copyright (C) 2008 Atmel Corporation
- *
- * Backlight driver using Atmel PWM peripheral.
- *
- * 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.
- */
-#include linux/init.h
-#include linux/kernel.h
-#include linux/module.h
-#include linux/platform_device.h
-#include linux/fb.h
-#include linux/gpio.h
-#include linux/backlight.h
-#include linux/atmel_pwm.h
-#include linux/atmel-pwm-bl.h
-#include linux/slab.h
-
-struct atmel_pwm_bl {
-   const struct atmel_pwm_bl_platform_data *pdata;
-   struct backlight_device *bldev;
-   struct platform_device  *pdev;
-   struct pwm_channel  pwmc;
-   int gpio_on;
-};
-
-static void atmel_pwm_bl_set_gpio_on(struct atmel_pwm_bl *pwmbl, int on)
-{
-   if (!gpio_is_valid(pwmbl-gpio_on))
-   return;
-
-   gpio_set_value(pwmbl-gpio_on, on ^ pwmbl-pdata-on_active_low);
-}
-
-static int atmel_pwm_bl_set_intensity(struct backlight_device *bd)
-{
-   struct atmel_pwm_bl *pwmbl = bl_get_data(bd);
-   int intensity = bd-props.brightness;
-   int pwm_duty;
-
-   if (bd-props.power != FB_BLANK_UNBLANK)
-   intensity = 0;
-   if (bd-props.fb_blank != FB_BLANK_UNBLANK)
-   intensity = 0;
-
-   if (pwmbl-pdata-pwm_active_low)
-   pwm_duty = pwmbl-pdata-pwm_duty_min + intensity;
-   else
-   pwm_duty = pwmbl-pdata-pwm_duty_max - intensity;
-
-   if (pwm_duty  pwmbl-pdata-pwm_duty_max)
-   pwm_duty = pwmbl-pdata-pwm_duty_max;
-   if (pwm_duty  pwmbl-pdata-pwm_duty_min)
-   pwm_duty = pwmbl-pdata-pwm_duty_min;
-
-   if (!intensity) {
-   atmel_pwm_bl_set_gpio_on(pwmbl, 0);
-   pwm_channel_writel(pwmbl-pwmc, PWM_CUPD, pwm_duty);
-   pwm_channel_disable(pwmbl-pwmc);
-   } else {
-   pwm_channel_enable(pwmbl-pwmc);
-   pwm_channel_writel(pwmbl-pwmc, PWM_CUPD, pwm_duty);
-   atmel_pwm_bl_set_gpio_on(pwmbl, 1);
-   }
-
-   return 0;
-}
-
-static int atmel_pwm_bl_get_intensity(struct backlight_device *bd)
-{
-   struct atmel_pwm_bl *pwmbl = bl_get_data(bd);
-   u32 cdty;
-   u32 intensity;
-
-   cdty = pwm_channel_readl(pwmbl-pwmc, PWM_CDTY);
-   if (pwmbl-pdata-pwm_active_low

[PATCH 06/16] ARM: at91: remove useless at91_pwm_leds()

2014-03-19 Thread Alexandre Belloni
Now that all at91 boards using leds-atmel-pwm switched to leds-pwm, the
at91_pwm_leds() function is not used anymore.

Signed-off-by: Alexandre Belloni alexandre.bell...@free-electrons.com
---
 arch/arm/mach-at91/board.h |  1 -
 arch/arm/mach-at91/leds.c  | 37 -
 2 files changed, 38 deletions(-)

diff --git a/arch/arm/mach-at91/board.h b/arch/arm/mach-at91/board.h
index 4e773b55bc2d..836e9a537e0c 100644
--- a/arch/arm/mach-at91/board.h
+++ b/arch/arm/mach-at91/board.h
@@ -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
diff --git a/arch/arm/mach-at91/leds.c b/arch/arm/mach-at91/leds.c
index 3e22978b5547..684723ba24f3 100644
--- a/arch/arm/mach-at91/leds.c
+++ b/arch/arm/mach-at91/leds.c
@@ -53,40 +53,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
-- 
1.8.3.2

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 16/16] misc: atmel_pwm: remove obsolete driver

2014-03-19 Thread Alexandre Belloni
The misc/atmel_pwm is not used by any mainlined boards and has been replaced by
the pwm-driver using the generic PWM framework.

Signed-off-by: Alexandre Belloni alexandre.bell...@free-electrons.com
---
 drivers/misc/Kconfig  |   9 --
 drivers/misc/Makefile |   1 -
 drivers/misc/atmel_pwm.c  | 402 --
 include/linux/atmel_pwm.h |  70 
 4 files changed, 482 deletions(-)
 delete mode 100644 drivers/misc/atmel_pwm.c
 delete mode 100644 include/linux/atmel_pwm.h

diff --git a/drivers/misc/Kconfig b/drivers/misc/Kconfig
index 6cb388e8fb7d..64ab12b8de9e 100644
--- a/drivers/misc/Kconfig
+++ b/drivers/misc/Kconfig
@@ -51,15 +51,6 @@ config AD525X_DPOT_SPI
  To compile this driver as a module, choose M here: the
  module will be called ad525x_dpot-spi.
 
-config ATMEL_PWM
-   tristate Atmel AT32/AT91 PWM support
-   depends on HAVE_CLK
-   help
- This option enables device driver support for the PWM channels
- on certain Atmel processors.  Pulse Width Modulation is used for
- purposes including software controlled power-efficient backlights
- on LCD displays, motor control, and waveform generation.
-
 config ATMEL_TCLIB
bool Atmel AT32/AT91 Timer/Counter Library
depends on (AVR32 || ARCH_AT91)
diff --git a/drivers/misc/Makefile b/drivers/misc/Makefile
index 99b9424ce31d..8dd44f924cb0 100644
--- a/drivers/misc/Makefile
+++ b/drivers/misc/Makefile
@@ -7,7 +7,6 @@ obj-$(CONFIG_AD525X_DPOT)   += ad525x_dpot.o
 obj-$(CONFIG_AD525X_DPOT_I2C)  += ad525x_dpot-i2c.o
 obj-$(CONFIG_AD525X_DPOT_SPI)  += ad525x_dpot-spi.o
 obj-$(CONFIG_INTEL_MID_PTI)+= pti.o
-obj-$(CONFIG_ATMEL_PWM)+= atmel_pwm.o
 obj-$(CONFIG_ATMEL_SSC)+= atmel-ssc.o
 obj-$(CONFIG_ATMEL_TCLIB)  += atmel_tclib.o
 obj-$(CONFIG_BMP085)   += bmp085.o
diff --git a/drivers/misc/atmel_pwm.c b/drivers/misc/atmel_pwm.c
deleted file mode 100644
index a6dc56e1bc58..
--- a/drivers/misc/atmel_pwm.c
+++ /dev/null
@@ -1,402 +0,0 @@
-#include linux/module.h
-#include linux/clk.h
-#include linux/err.h
-#include linux/slab.h
-#include linux/io.h
-#include linux/interrupt.h
-#include linux/platform_device.h
-#include linux/atmel_pwm.h
-
-
-/*
- * This is a simple driver for the PWM controller found in various newer
- * Atmel SOCs, including the AVR32 series and the AT91sam9263.
- *
- * Chips with current Linux ports have only 4 PWM channels, out of max 32.
- * AT32UC3A and AT32UC3B chips have 7 channels (but currently no Linux).
- * Docs are inconsistent about the width of the channel counter registers;
- * it's at least 16 bits, but several places say 20 bits.
- */
-#definePWM_NCHAN   4   /* max 32 */
-
-struct pwm {
-   spinlock_t  lock;
-   struct platform_device  *pdev;
-   u32 mask;
-   int irq;
-   void __iomem*base;
-   struct clk  *clk;
-   struct pwm_channel  *channel[PWM_NCHAN];
-   void(*handler[PWM_NCHAN])(struct pwm_channel *);
-};
-
-
-/* global PWM controller registers */
-#define PWM_MR 0x00
-#define PWM_ENA0x04
-#define PWM_DIS0x08
-#define PWM_SR 0x0c
-#define PWM_IER0x10
-#define PWM_IDR0x14
-#define PWM_IMR0x18
-#define PWM_ISR0x1c
-
-static inline void pwm_writel(const struct pwm *p, unsigned offset, u32 val)
-{
-   __raw_writel(val, p-base + offset);
-}
-
-static inline u32 pwm_readl(const struct pwm *p, unsigned offset)
-{
-   return __raw_readl(p-base + offset);
-}
-
-static inline void __iomem *pwmc_regs(const struct pwm *p, int index)
-{
-   return p-base + 0x200 + index * 0x20;
-}
-
-static struct pwm *pwm;
-
-static void pwm_dumpregs(struct pwm_channel *ch, char *tag)
-{
-   struct device   *dev = pwm-pdev-dev;
-
-   dev_dbg(dev, %s: mr %08x, sr %08x, imr %08x\n,
-   tag,
-   pwm_readl(pwm, PWM_MR),
-   pwm_readl(pwm, PWM_SR),
-   pwm_readl(pwm, PWM_IMR));
-   dev_dbg(dev,
-   pwm ch%d - mr %08x, dty %u, prd %u, cnt %u\n,
-   ch-index,
-   pwm_channel_readl(ch, PWM_CMR),
-   pwm_channel_readl(ch, PWM_CDTY),
-   pwm_channel_readl(ch, PWM_CPRD),
-   pwm_channel_readl(ch, PWM_CCNT));
-}
-
-
-/**
- * pwm_channel_alloc - allocate an unused PWM channel
- * @index: identifies the channel
- * @ch: structure to be initialized
- *
- * Drivers allocate PWM channels according to the board's wiring, and
- * matching board-specific setup code.  Returns zero or negative errno.
- */
-int pwm_channel_alloc(int index, struct pwm_channel *ch)
-{
-   unsigned long   flags;
-   int status = 0;
-
-   if (!pwm)
-   return -EPROBE_DEFER

[PATCH 15/16] leds: atmel-pwm: remove obsolete driver

2014-03-19 Thread Alexandre Belloni
The leds-atmel-pwmdriver is now obsolete. It is not used by any mainlined boards
and is replaced by the generic leds_pwm with the pawm-atmel driver using the
generic PWM framework.

Signed-off-by: Alexandre Belloni alexandre.bell...@free-electrons.com
---
 drivers/leds/Kconfig  |   8 ---
 drivers/leds/Makefile |   1 -
 drivers/leds/leds-atmel-pwm.c | 149 --
 3 files changed, 158 deletions(-)
 delete mode 100644 drivers/leds/leds-atmel-pwm.c

diff --git a/drivers/leds/Kconfig b/drivers/leds/Kconfig
index 72156c123033..e7aca5f1e396 100644
--- a/drivers/leds/Kconfig
+++ b/drivers/leds/Kconfig
@@ -32,14 +32,6 @@ config LEDS_88PM860X
  This option enables support for on-chip LED drivers found on Marvell
  Semiconductor 88PM8606 PMIC.
 
-config LEDS_ATMEL_PWM
-   tristate LED Support using Atmel PWM outputs
-   depends on LEDS_CLASS
-   depends on ATMEL_PWM
-   help
- This option enables support for LEDs driven using outputs
- of the dedicated PWM controller found on newer Atmel SOCs.
-
 config LEDS_LM3530
tristate LCD Backlight driver for LM3530
depends on LEDS_CLASS
diff --git a/drivers/leds/Makefile b/drivers/leds/Makefile
index 3cd76dbd9be2..6ee06559db45 100644
--- a/drivers/leds/Makefile
+++ b/drivers/leds/Makefile
@@ -6,7 +6,6 @@ obj-$(CONFIG_LEDS_TRIGGERS) += led-triggers.o
 
 # LED Platform Drivers
 obj-$(CONFIG_LEDS_88PM860X)+= leds-88pm860x.o
-obj-$(CONFIG_LEDS_ATMEL_PWM)   += leds-atmel-pwm.o
 obj-$(CONFIG_LEDS_BD2802)  += leds-bd2802.o
 obj-$(CONFIG_LEDS_LOCOMO)  += leds-locomo.o
 obj-$(CONFIG_LEDS_LM3530)  += leds-lm3530.o
diff --git a/drivers/leds/leds-atmel-pwm.c b/drivers/leds/leds-atmel-pwm.c
deleted file mode 100644
index 56cec8d6a2ac..
--- a/drivers/leds/leds-atmel-pwm.c
+++ /dev/null
@@ -1,149 +0,0 @@
-#include linux/kernel.h
-#include linux/platform_device.h
-#include linux/leds.h
-#include linux/io.h
-#include linux/atmel_pwm.h
-#include linux/slab.h
-#include linux/module.h
-
-
-struct pwmled {
-   struct led_classdev cdev;
-   struct pwm_channel  pwmc;
-   struct gpio_led *desc;
-   u32 mult;
-   u8  active_low;
-};
-
-
-/*
- * For simplicity, we use brightness as if it were a linear function
- * of PWM duty cycle.  However, a logarithmic function of duty cycle is
- * probably a better match for perceived brightness: two is half as bright
- * as four, four is half as bright as eight, etc
- */
-static void pwmled_brightness(struct led_classdev *cdev, enum led_brightness b)
-{
-   struct pwmled*led;
-
-   /* update the duty cycle for the *next* period */
-   led = container_of(cdev, struct pwmled, cdev);
-   pwm_channel_writel(led-pwmc, PWM_CUPD, led-mult * (unsigned) b);
-}
-
-/*
- * NOTE:  we reuse the platform_data structure of GPIO leds,
- * but repurpose its gpio number as a PWM channel number.
- */
-static int pwmled_probe(struct platform_device *pdev)
-{
-   const struct gpio_led_platform_data *pdata;
-   struct pwmled   *leds;
-   int i;
-   int status;
-
-   pdata = dev_get_platdata(pdev-dev);
-   if (!pdata || pdata-num_leds  1)
-   return -ENODEV;
-
-   leds = devm_kzalloc(pdev-dev, pdata-num_leds * sizeof(*leds),
-   GFP_KERNEL);
-   if (!leds)
-   return -ENOMEM;
-
-   for (i = 0; i  pdata-num_leds; i++) {
-   struct pwmled   *led = leds + i;
-   const struct gpio_led   *dat = pdata-leds + i;
-   u32 tmp;
-
-   led-cdev.name = dat-name;
-   led-cdev.brightness = LED_OFF;
-   led-cdev.brightness_set = pwmled_brightness;
-   led-cdev.default_trigger = dat-default_trigger;
-
-   led-active_low = dat-active_low;
-
-   status = pwm_channel_alloc(dat-gpio, led-pwmc);
-   if (status  0)
-   goto err;
-
-   /*
-* Prescale clock by 2^x, so PWM counts in low MHz.
-* Start each cycle with the LED active, so increasing
-* the duty cycle gives us more time on (== brighter).
-*/
-   tmp = 5;
-   if (!led-active_low)
-   tmp |= PWM_CPR_CPOL;
-   pwm_channel_writel(led-pwmc, PWM_CMR, tmp);
-
-   /*
-* Pick a period so PWM cycles at 100+ Hz; and a multiplier
-* for scaling duty cycle:  brightness * mult.
-*/
-   tmp = (led-pwmc.mck / (1  5)) / 100;
-   tmp /= 255;
-   led-mult = tmp;
-   pwm_channel_writel(led-pwmc

[PATCH 02/16] ARM: at91: sam9m10g45ek: use generic leds_pwm driver

2014-03-19 Thread Alexandre Belloni
Switch to the generic leds_pwm driver instead of leds-atmel-pwm.

Signed-off-by: Alexandre Belloni alexandre.bell...@free-electrons.com
---
 arch/arm/mach-at91/board-sam9m10g45ek.c | 43 ++---
 1 file changed, 34 insertions(+), 9 deletions(-)

diff --git a/arch/arm/mach-at91/board-sam9m10g45ek.c 
b/arch/arm/mach-at91/board-sam9m10g45ek.c
index f2f7ce9643ce..a98e92525fdb 100644
--- a/arch/arm/mach-at91/board-sam9m10g45ek.c
+++ b/arch/arm/mach-at91/board-sam9m10g45ek.c
@@ -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
 
@@ -415,7 +417,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,
@@ -429,22 +431,42 @@ 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),
+};
+
+#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,
+   .pwm_period_ns  = 5000,
+   .active_low = 1,
},
-#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)
@@ -485,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));
 }
-- 
1.8.3.2

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 12/16] avr32: favr-32: use generic pwm_bl driver

2014-03-19 Thread Alexandre Belloni
Switch to the generic pwm_bl driver instead of atmel-pwm-bl.

Signed-off-by: Alexandre Belloni alexandre.bell...@free-electrons.com
---
 arch/avr32/boards/favr-32/setup.c| 49 +++-
 arch/avr32/configs/favr-32_defconfig |  6 ++---
 2 files changed, 34 insertions(+), 21 deletions(-)

diff --git a/arch/avr32/boards/favr-32/setup.c 
b/arch/avr32/boards/favr-32/setup.c
index 1f121497b517..391f026705a5 100644
--- a/arch/avr32/boards/favr-32/setup.c
+++ b/arch/avr32/boards/favr-32/setup.c
@@ -18,7 +18,10 @@
 #include linux/gpio.h
 #include linux/leds.h
 #include linux/atmel-mci.h
-#include linux/atmel-pwm-bl.h
+#include linux/pwm.h
+#include linux/pwm_backlight.h
+#include linux/regulator/fixed.h
+#include linux/regulator/machine.h
 #include linux/spi/spi.h
 #include linux/spi/ads7846.h
 
@@ -33,6 +36,8 @@
 #include mach/board.h
 #include mach/portmux.h
 
+#define PWM_BL_CH 2
+
 /* Oscillator frequencies. These are board-specific */
 unsigned long at32_board_osc_rates[3] = {
[0] = 32768,/* 32.768 kHz on RTC osc */
@@ -227,29 +232,37 @@ void __init favr32_setup_leds(void)
platform_device_register(favr32_led_dev);
 }
 
-static struct atmel_pwm_bl_platform_data atmel_pwm_bl_pdata = {
-   .pwm_channel= 2,
-   .pwm_frequency  = 20,
-   .pwm_compare_max= 345,
-   .pwm_duty_max   = 345,
-   .pwm_duty_min   = 90,
-   .pwm_active_low = 1,
-   .gpio_on= GPIO_PIN_PA(28),
-   .on_active_low  = 0,
+static struct pwm_lookup pwm_lookup[] = {
+   PWM_LOOKUP(at91sam9rl-pwm, PWM_BL_CH, pwm-backlight.0, NULL),
 };
 
-static struct platform_device atmel_pwm_bl_dev = {
-   .name   = atmel-pwm-bl,
-   .id = 0,
-   .dev= {
-   .platform_data = atmel_pwm_bl_pdata,
+static struct regulator_consumer_supply fixed_power_consumers[] = {
+   REGULATOR_SUPPLY(power, pwm-backlight.0),
+};
+
+static struct platform_pwm_backlight_data pwm_bl_data = {
+   .enable_gpio= GPIO_PIN_PA(28),
+   .pwm_period_ns  = 5000,
+   .max_brightness = 255,
+   .dft_brightness = 255,
+   .lth_brightness = 50,
+   .pwm_active_low = true,
+};
+
+static struct platform_device pwm_bl_device = {
+   .name = pwm-backlight,
+   .dev = {
+   .platform_data = pwm_bl_data,
},
 };
 
 static void __init favr32_setup_atmel_pwm_bl(void)
 {
-   platform_device_register(atmel_pwm_bl_dev);
-   at32_select_gpio(atmel_pwm_bl_pdata.gpio_on, 0);
+   pwm_add_table(pwm_lookup, ARRAY_SIZE(pwm_lookup));
+   regulator_register_always_on(0, fixed, fixed_power_consumers,
+   ARRAY_SIZE(fixed_power_consumers), 330);
+   platform_device_register(pwm_bl_device);
+   at32_select_gpio(pwm_bl_data.enable_gpio, 0);
 }
 
 void __init setup_board(void)
@@ -339,7 +352,7 @@ static int __init favr32_init(void)
 
set_abdac_rate(at32_add_device_abdac(0, abdac0_data));
 
-   at32_add_device_pwm(1  atmel_pwm_bl_pdata.pwm_channel);
+   at32_add_device_pwm(1  PWM_BL_CH);
at32_add_device_spi(1, spi1_board_info, ARRAY_SIZE(spi1_board_info));
at32_add_device_mci(0, mci0_data);
at32_add_device_usba(0, NULL);
diff --git a/arch/avr32/configs/favr-32_defconfig 
b/arch/avr32/configs/favr-32_defconfig
index 07bed3f7eb5e..b3eb67dc05ac 100644
--- a/arch/avr32/configs/favr-32_defconfig
+++ b/arch/avr32/configs/favr-32_defconfig
@@ -67,7 +67,6 @@ CONFIG_MTD_PHYSMAP=y
 CONFIG_BLK_DEV_LOOP=m
 CONFIG_BLK_DEV_NBD=m
 CONFIG_BLK_DEV_RAM=m
-CONFIG_ATMEL_PWM=m
 CONFIG_ATMEL_TCLIB=y
 CONFIG_ATMEL_SSC=m
 CONFIG_NETDEVICES=y
@@ -108,7 +107,7 @@ CONFIG_FB=y
 CONFIG_FB_ATMEL=y
 CONFIG_BACKLIGHT_LCD_SUPPORT=y
 # CONFIG_LCD_CLASS_DEVICE is not set
-CONFIG_BACKLIGHT_ATMEL_PWM=m
+CONFIG_BACKLIGHT_PWM=m
 CONFIG_SOUND=m
 CONFIG_SOUND_PRIME=m
 # CONFIG_HID_SUPPORT is not set
@@ -123,7 +122,6 @@ CONFIG_MMC=y
 CONFIG_MMC_ATMELMCI=y
 CONFIG_NEW_LEDS=y
 CONFIG_LEDS_CLASS=y
-CONFIG_LEDS_ATMEL_PWM=m
 CONFIG_LEDS_GPIO=y
 CONFIG_LEDS_TRIGGERS=y
 CONFIG_LEDS_TRIGGER_TIMER=y
@@ -132,6 +130,8 @@ CONFIG_LEDS_TRIGGER_DEFAULT_ON=y
 CONFIG_RTC_CLASS=y
 CONFIG_RTC_DRV_AT32AP700X=y
 CONFIG_DMADEVICES=y
+CONFIG_PWM=y
+CONFIG_PWM_ATMEL=y
 CONFIG_EXT2_FS=y
 CONFIG_EXT3_FS=y
 # CONFIG_EXT3_FS_XATTR is not set
-- 
1.8.3.2

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 11/16] avr32: merisc: use generic leds_pwm driver

2014-03-19 Thread Alexandre Belloni
Switch to the generic leds_pwm driver instead of leds-atmel-pwm.

Signed-off-by: Alexandre Belloni alexandre.bell...@free-electrons.com
---
 arch/avr32/boards/merisc/setup.c | 34 +-
 1 file changed, 21 insertions(+), 13 deletions(-)

diff --git a/arch/avr32/boards/merisc/setup.c b/arch/avr32/boards/merisc/setup.c
index ed137e335796..b0980c1946a7 100644
--- a/arch/avr32/boards/merisc/setup.c
+++ b/arch/avr32/boards/merisc/setup.c
@@ -22,6 +22,8 @@
 #include linux/irq.h
 #include linux/fb.h
 #include linux/atmel-mci.h
+#include linux/pwm.h
+#include linux/leds_pwm.h
 
 #include asm/io.h
 #include asm/setup.h
@@ -167,24 +169,29 @@ static struct i2c_board_info __initdata i2c_info[] = {
},
 };
 
-#ifdef CONFIG_LEDS_ATMEL_PWM
-static struct gpio_led stk_pwm_led[] = {
+#if IS_ENABLED(CONFIG_LEDS_PWM)
+static struct pwm_lookup pwm_lookup[] = {
+   PWM_LOOKUP(at91sam9rl-pwm, 0, leds_pwm, backlight),
+};
+
+static struct led_pwm pwm_leds[] = {
{
.name   = backlight,
-   .gpio   = 0,/* PWM channel 0 (LCD backlight) */
+   .max_brightness = 255,
+   .pwm_period_ns  = 5000,
},
 };
 
-static struct gpio_led_platform_data stk_pwm_led_data = {
-   .num_leds   = ARRAY_SIZE(stk_pwm_led),
-   .leds   = stk_pwm_led,
+static struct led_pwm_platform_data pwm_data = {
+   .num_leds   = ARRAY_SIZE(pwm_leds),
+   .leds   = pwm_leds,
 };
 
-static struct platform_device stk_pwm_led_dev = {
-   .name   = leds-atmel-pwm,
-   .id = -1,
-   .dev= {
-   .platform_data  = stk_pwm_led_data,
+static struct platform_device leds_pwm = {
+   .name   = leds_pwm,
+   .id = -1,
+   .dev= {
+   .platform_data = pwm_data,
},
 };
 #endif
@@ -278,9 +285,10 @@ static int __init merisc_init(void)
 
at32_add_device_mci(0, mci0_data);
 
-#ifdef CONFIG_LEDS_ATMEL_PWM
+#if IS_ENABLED(CONFIG_LEDS_PWM)
+   pwm_add_table(pwm_lookup, ARRAY_SIZE(pwm_lookup));
at32_add_device_pwm((1  0) | (1  2));
-   platform_device_register(stk_pwm_led_dev);
+   platform_device_register(leds_pwm);
 #else
at32_add_device_pwm((1  2));
 #endif
-- 
1.8.3.2

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 01/16] ARM: at91: at91sam9g45: switch to generic PWM framework

2014-03-19 Thread Alexandre Belloni
Switch to the pwm/pwm-atmel driver instead of misc/atmel_pwm

Signed-off-by: Alexandre Belloni alexandre.bell...@free-electrons.com
---
 arch/arm/mach-at91/at91sam9g45.c |  1 +
 arch/arm/mach-at91/at91sam9g45_devices.c | 11 ++-
 2 files changed, 3 insertions(+), 9 deletions(-)

diff --git a/arch/arm/mach-at91/at91sam9g45.c b/arch/arm/mach-at91/at91sam9g45.c
index 3c519a7a938f..2d3c6e1ac158 100644
--- a/arch/arm/mach-at91/at91sam9g45.c
+++ b/arch/arm/mach-at91/at91sam9g45.c
@@ -250,6 +250,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, ee00.serial, mck),
CLKDEV_CON_DEV_ID(usart, fff8c000.serial, usart0_clk),
diff --git a/arch/arm/mach-at91/at91sam9g45_devices.c 
b/arch/arm/mach-at91/at91sam9g45_devices.c
index 87135a61357d..25ba920cbe84 100644
--- a/arch/arm/mach-at91/at91sam9g45_devices.c
+++ b/arch/arm/mach-at91/at91sam9g45_devices.c
@@ -1332,9 +1332,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,
@@ -1349,11 +1347,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),
 };
@@ -1372,8 +1367,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
-- 
1.8.3.2

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 07/16] PWM: atmel: allow building for AVR32

2014-03-19 Thread Alexandre Belloni
The Atmel PWM IP can be found on avr32 chips. This allows selecting and building
the driver on avr32.

Signed-off-by: Alexandre Belloni alexandre.bell...@free-electrons.com
---
 drivers/pwm/Kconfig | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/pwm/Kconfig b/drivers/pwm/Kconfig
index 22f2f2857b82..892dd1ab4134 100644
--- a/drivers/pwm/Kconfig
+++ b/drivers/pwm/Kconfig
@@ -43,7 +43,7 @@ config PWM_AB8500
 
 config PWM_ATMEL
tristate Atmel PWM support
-   depends on ARCH_AT91
+   depends on ARCH_AT91 || AVR32
help
  Generic PWM framework driver for Atmel SoC.
 
-- 
1.8.3.2

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 09/16] avr32/at32ap: switch to the generic PWM framework

2014-03-19 Thread Alexandre Belloni
Switch to the pwm/pwm-atmel driver instead of misc/atmel_pwm

Signed-off-by: Alexandre Belloni alexandre.bell...@free-electrons.com
---
 arch/avr32/mach-at32ap/at32ap700x.c | 7 ++-
 1 file changed, 2 insertions(+), 5 deletions(-)

diff --git a/arch/avr32/mach-at32ap/at32ap700x.c 
b/arch/avr32/mach-at32ap/at32ap700x.c
index a1f4d1e91b52..db85b5ec3351 100644
--- a/arch/avr32/mach-at32ap/at32ap700x.c
+++ b/arch/avr32/mach-at32ap/at32ap700x.c
@@ -1553,7 +1553,7 @@ static struct resource atmel_pwm0_resource[] __initdata = 
{
IRQ(24),
 };
 static struct clk atmel_pwm0_mck = {
-   .name   = pwm_clk,
+   .name   = at91sam9rl-pwm,
.parent = pbb_clk,
.mode   = pbb_clk_mode,
.get_rate   = pbb_clk_get_rate,
@@ -1568,7 +1568,7 @@ struct platform_device *__init at32_add_device_pwm(u32 
mask)
if (!mask)
return NULL;
 
-   pdev = platform_device_alloc(atmel_pwm, 0);
+   pdev = platform_device_alloc(at91sam9rl-pwm, 0);
if (!pdev)
return NULL;
 
@@ -1576,9 +1576,6 @@ struct platform_device *__init at32_add_device_pwm(u32 
mask)
ARRAY_SIZE(atmel_pwm0_resource)))
goto out_free_pdev;
 
-   if (platform_device_add_data(pdev, mask, sizeof(mask)))
-   goto out_free_pdev;
-
pin_mask = 0;
if (mask  (1  0))
pin_mask |= (1  28);
-- 
1.8.3.2

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 08/16] backlight: pwm_bl: set pwm polarity when using platform data

2014-03-19 Thread Alexandre Belloni
Set inversed polarity when .pwm_active_low is set in the platform_data. With
device tree, this is taken care of by of_pwm_xlate_with_flags(), called from
of_pwm_get().

Signed-off-by: Alexandre Belloni alexandre.bell...@free-electrons.com
---
 drivers/video/backlight/pwm_bl.c | 8 
 include/linux/pwm_backlight.h| 1 +
 2 files changed, 9 insertions(+)

diff --git a/drivers/video/backlight/pwm_bl.c b/drivers/video/backlight/pwm_bl.c
index b75201ff46f6..ffdd3b2b2742 100644
--- a/drivers/video/backlight/pwm_bl.c
+++ b/drivers/video/backlight/pwm_bl.c
@@ -309,6 +309,14 @@ static int pwm_backlight_probe(struct platform_device 
*pdev)
if (data-pwm_period_ns  0)
pwm_set_period(pb-pwm, data-pwm_period_ns);
 
+   /*
+* The DT case is taking care of polarity in of_pwm_get(). For the
+* non-DT case, set the polarity from platform data.
+*/
+   if (data-pwm_active_low)
+   if (pwm_set_polarity(pb-pwm, PWM_POLARITY_INVERSED))
+   dev_err(pdev-dev, impossible to invert polarity\n);
+
pb-period = pwm_get_period(pb-pwm);
pb-lth_brightness = data-lth_brightness * (pb-period / pb-scale);
 
diff --git a/include/linux/pwm_backlight.h b/include/linux/pwm_backlight.h
index 2de2e275b2cb..b924fce5c97a 100644
--- a/include/linux/pwm_backlight.h
+++ b/include/linux/pwm_backlight.h
@@ -15,6 +15,7 @@ struct platform_pwm_backlight_data {
unsigned int dft_brightness;
unsigned int lth_brightness;
unsigned int pwm_period_ns;
+   bool pwm_active_low;
unsigned int *levels;
int enable_gpio;
unsigned long enable_gpio_flags;
-- 
1.8.3.2

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 00/16] move at91 and avr32 to the PWM framework, remove obsolete drivers

2014-03-19 Thread Alexandre Belloni
Hi,

This patch set swtiches the at91 and avr32 SoCs and board to the generic PWM
framework. This allows to remove the obsolete leds-atmel-pwm, atmel-pwm-bl and
atmel_pwm drivers.

The first 6 patches take care of the AT91 boards and removes a useless function
in the process.

Patch 7 makes pwm-ateml buildable for AVR32

Patch 8 allows setting the pwm polarity for pwm_bl when using platform data.
This is required afterwards for the favr-32

Patches 9-13 take care of the AVR32 boards. This has only been compile tested as
I don't own any of those boards.

And the last 3 patches are removing the now obsolete drivers.

As a note, the atmel_pwm driver has two features not yet available through
pwm-atmel:
 - it is possible to pass an IRQ handler that will get called each time one of
   the channel period has been acheived.
 - it was possible to set clka and clkb, two clock that divided mck before
   feeding the pwm controller.

Those features are not used by anything in the mainline. I'm not sure we can
implement the first one. We'll get back the second one once all the boards have
swtiched to the common clock framework.


Alexandre Belloni (16):
  ARM: at91: at91sam9g45: switch to generic PWM framework
  ARM: at91: sam9m10g45ek: use generic leds_pwm driver
  ARM: at91: at91sam9263: switch to generic PWM framework
  ARM: at91: sam9263ek: use generic leds_pwm driver
  ARM: at91: at91sam9rl: switch to generic PWM framework
  ARM: at91: remove useless at91_pwm_leds()
  PWM: atmel: allow building for AVR32
  backlight: pwm_bl: set pwm polarity when using platform data
  avr32/at32ap: switch to the generic PWM framework
  avr32: MRMT: use generic leds_pwm driver
  avr32: merisc: use generic leds_pwm driver
  avr32: favr-32: use generic pwm_bl driver
  avr32: update defconfig to use the generic PWM framework
  backlight: atmel-pwm-bl: remove obsolete driver
  leds: atmel-pwm: remove obsolete driver
  misc: atmel_pwm: remove obsolete driver

 arch/arm/mach-at91/at91sam9263.c   |   1 +
 arch/arm/mach-at91/at91sam9263_devices.c   |  11 +-
 arch/arm/mach-at91/at91sam9g45.c   |   1 +
 arch/arm/mach-at91/at91sam9g45_devices.c   |  11 +-
 arch/arm/mach-at91/at91sam9rl.c|   1 +
 arch/arm/mach-at91/at91sam9rl_devices.c|  11 +-
 arch/arm/mach-at91/board-sam9263ek.c   |  56 +++-
 arch/arm/mach-at91/board-sam9m10g45ek.c|  43 ++-
 arch/arm/mach-at91/board.h |   1 -
 arch/arm/mach-at91/leds.c  |  37 ---
 arch/avr32/boards/atngw100/mrmt.c  |  35 ++-
 arch/avr32/boards/favr-32/setup.c  |  49 ++--
 arch/avr32/boards/merisc/setup.c   |  34 ++-
 arch/avr32/configs/atngw100_mrmt_defconfig |   5 +-
 arch/avr32/configs/atstk1002_defconfig |   5 +-
 arch/avr32/configs/atstk1003_defconfig |   5 +-
 arch/avr32/configs/atstk1004_defconfig |   5 +-
 arch/avr32/configs/atstk1006_defconfig |   5 +-
 arch/avr32/configs/favr-32_defconfig   |   6 +-
 arch/avr32/configs/merisc_defconfig|   5 +-
 arch/avr32/mach-at32ap/at32ap700x.c|   7 +-
 drivers/leds/Kconfig   |   8 -
 drivers/leds/Makefile  |   1 -
 drivers/leds/leds-atmel-pwm.c  | 149 ---
 drivers/misc/Kconfig   |   9 -
 drivers/misc/Makefile  |   1 -
 drivers/misc/atmel_pwm.c   | 402 -
 drivers/pwm/Kconfig|   2 +-
 drivers/video/backlight/Kconfig|  11 -
 drivers/video/backlight/Makefile   |   1 -
 drivers/video/backlight/atmel-pwm-bl.c | 223 
 drivers/video/backlight/pwm_bl.c   |   8 +
 include/linux/atmel-pwm-bl.h   |  43 ---
 include/linux/atmel_pwm.h  |  70 -
 include/linux/pwm_backlight.h  |   1 +
 35 files changed, 199 insertions(+), 1064 deletions(-)
 delete mode 100644 drivers/leds/leds-atmel-pwm.c
 delete mode 100644 drivers/misc/atmel_pwm.c
 delete mode 100644 drivers/video/backlight/atmel-pwm-bl.c
 delete mode 100644 include/linux/atmel-pwm-bl.h
 delete mode 100644 include/linux/atmel_pwm.h

-- 
1.8.3.2

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 03/16] ARM: at91: at91sam9263: switch to generic PWM framework

2014-03-19 Thread Alexandre Belloni
Switch to the pwm/pwm-atmel driver instead of misc/atmel_pwm

Signed-off-by: Alexandre Belloni alexandre.bell...@free-electrons.com
---
 arch/arm/mach-at91/at91sam9263.c |  1 +
 arch/arm/mach-at91/at91sam9263_devices.c | 11 ++-
 2 files changed, 3 insertions(+), 9 deletions(-)

diff --git a/arch/arm/mach-at91/at91sam9263.c b/arch/arm/mach-at91/at91sam9263.c
index 37b90f4b990c..d0c2d4955cd7 100644
--- a/arch/arm/mach-at91/at91sam9263.c
+++ b/arch/arm/mach-at91/at91sam9263.c
@@ -198,6 +198,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),
diff --git a/arch/arm/mach-at91/at91sam9263_devices.c 
b/arch/arm/mach-at91/at91sam9263_devices.c
index 4aeadddbc181..160acd96cdda 100644
--- a/arch/arm/mach-at91/at91sam9263_devices.c
+++ b/arch/arm/mach-at91/at91sam9263_devices.c
@@ -1129,9 +1129,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,
@@ -1146,11 +1144,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),
 };
@@ -1169,8 +1164,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
-- 
1.8.3.2

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 05/16] ARM: at91: at91sam9rl: switch to generic PWM framework

2014-03-19 Thread Alexandre Belloni
Switch to the pwm/pwm-atmel driver instead of misc/atmel_pwm

Signed-off-by: Alexandre Belloni alexandre.bell...@free-electrons.com
---
 arch/arm/mach-at91/at91sam9rl.c |  1 +
 arch/arm/mach-at91/at91sam9rl_devices.c | 11 ++-
 2 files changed, 3 insertions(+), 9 deletions(-)

diff --git a/arch/arm/mach-at91/at91sam9rl.c b/arch/arm/mach-at91/at91sam9rl.c
index 4d2006351d1d..bc035a9ff53c 100644
--- a/arch/arm/mach-at91/at91sam9rl.c
+++ b/arch/arm/mach-at91/at91sam9rl.c
@@ -199,6 +199,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),
diff --git a/arch/arm/mach-at91/at91sam9rl_devices.c 
b/arch/arm/mach-at91/at91sam9rl_devices.c
index 9ccae034119c..a396d6d56ffe 100644
--- a/arch/arm/mach-at91/at91sam9rl_devices.c
+++ b/arch/arm/mach-at91/at91sam9rl_devices.c
@@ -797,9 +797,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,
@@ -814,11 +812,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),
 };
@@ -837,8 +832,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
-- 
1.8.3.2

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 04/16] ARM: at91: sam9263ek: use generic leds_pwm driver

2014-03-19 Thread Alexandre Belloni
Switch to the generic leds_pwm driver instead of leds-atmel-pwm.

Signed-off-by: Alexandre Belloni alexandre.bell...@free-electrons.com
---
 arch/arm/mach-at91/board-sam9263ek.c | 56 ++--
 1 file changed, 48 insertions(+), 8 deletions(-)

diff --git a/arch/arm/mach-at91/board-sam9263ek.c 
b/arch/arm/mach-at91/board-sam9263ek.c
index 2f931915c80c..f8496868d9ba 100644
--- a/arch/arm/mach-at91/board-sam9263ek.c
+++ b/arch/arm/mach-at91/board-sam9263ek.c
@@ -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
 
@@ -368,21 +370,48 @@ 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),
+};
+
+#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,
+   .pwm_period_ns  = 5000,
+   .active_low = 1,
+   },
+};
+
+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
@@ -402,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 */
@@ -436,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)
-- 
1.8.3.2

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH 10/11] ARM: at91/dt: move at91sam9rl SoC to the new slow/main clock models

2014-03-19 Thread Alexandre Belloni
On 18/03/2014 at 21:18:43 +0100, Boris BREZILLON wrote :
 Move at91sam9rl SoC to the new main/slow clock model.
 
 Signed-off-by: Boris BREZILLON b.brezillon@gmail.com
 ---
  arch/arm/boot/dts/at91sam9rl.dtsi |   45 
 -
  1 file changed, 39 insertions(+), 6 deletions(-)
 
 diff --git a/arch/arm/boot/dts/at91sam9rl.dtsi 
 b/arch/arm/boot/dts/at91sam9rl.dtsi
 index 63e1784..b367047 100644
 --- a/arch/arm/boot/dts/at91sam9rl.dtsi
 +++ b/arch/arm/boot/dts/at91sam9rl.dtsi
 @@ -48,6 +48,20 @@
   reg = 0x2000 0x0400;
   };
  
 + clocks {
 + slow_xtal: slow_xtal {
 + compatible = fixed-clock;
 + #clock-cells = 0;
 + clock-frequency = 0;
 + };
 +
 + main_xtal: main_xtal {
 + compatible = fixed-clock;
 + #clock-cells = 0;
 + clock-frequency = 0;
 + };
 + };
 +
   ahb {
   compatible = simple-bus;
   #address-cells = 1;
 @@ -548,12 +562,6 @@
   #size-cells = 0;
   #interrupt-cells = 1;
  
 - clk32k: slck {
 - compatible = fixed-clock;
 - #clock-cells = 0;
 - clock-frequency = 32768;
 - };
 -
   main: mainck {
   compatible = 
 atmel,at91rm9200-clk-main;
   #clock-cells = 0;

Somewhere, around here, you forgot:
-   clocks = clk32k;
+   clocks = main_xtal;


 @@ -769,6 +777,31 @@
   interrupts = 1 IRQ_TYPE_LEVEL_HIGH 7;
   status = disabled;
   };
 +
 + sckc@fd50 {
 + compatible = atmel,at91sam9x5-sckc;
 +
 + slow_osc: slow_osc {
 + compatible = 
 atmel,at91sam9x5-clk-slow-osc;
 + #clock-cells = 0;
 + atmel,startup-time-usec = 120;
 + clocks = slow_xtal;
 + };
 +
 + slow_rc_osc: slow_rc_osc {
 + compatible = 
 atmel,at91sam9x5-clk-slow-rc-osc;
 + #clock-cells = 0;
 + atmel,startup-time-usec = 75;
 + clock-frequency = 32768;
 + clock-accuracy = 5000;
 + };
 +
 + clk32k: slck {
 + compatible = 
 atmel,at91sam9x5-clk-slow;
 + #clock-cells = 0;
 + clocks = slow_rc_osc slow_osc;
 + };
 + };
   };
   };
  
 -- 
 1.7.9.5
 

-- 
Alexandre Belloni, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH 11/11] ARM: at91/dt: define sam9rlek crystal frequencies

2014-03-19 Thread Alexandre Belloni
On 18/03/2014 at 21:18:44 +0100, Boris BREZILLON wrote :
 Define at91sam9rlek crystal frequencies.
 
 Signed-off-by: Boris BREZILLON b.brezillon@gmail.com

Acked-by: Alexandre Belloni alexandre.bell...@free-electrons.com

 ---
  arch/arm/boot/dts/at91sam9rlek.dts |8 
  1 file changed, 8 insertions(+)
 
 diff --git a/arch/arm/boot/dts/at91sam9rlek.dts 
 b/arch/arm/boot/dts/at91sam9rlek.dts
 index cddb378..85b68b9 100644
 --- a/arch/arm/boot/dts/at91sam9rlek.dts
 +++ b/arch/arm/boot/dts/at91sam9rlek.dts
 @@ -25,6 +25,14 @@
   #size-cells = 1;
   ranges;
  
 + slow_xtal: slow_xtal {
 + clock-frequency = 32768;
 + };
 +
 + main_xtal: main_xtal {
 + clock-frequency = 1200;
 + };
 +
   main_clock: clock {
   compatible = atmel,osc, fixed-clock;
   clock-frequency = 1200;
 -- 
 1.7.9.5
 

-- 
Alexandre Belloni, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH] ARM: at91: panic when the mck rate is zero

2014-03-20 Thread Alexandre Belloni
If the mck rate is zero, we'll hit the following warning:

WARNING: CPU: 0 PID: 0 at arch/arm/mach-at91/at91sam926x_time.c:257 
at91sam926x_pit_init+0x13c/0x260()

But the kernel will continue to try booting and face a lot of divisions by zero
when trying to handle the various clocks.

Signed-off-by: Alexandre Belloni alexandre.bell...@free-electrons.com
---
 arch/arm/mach-at91/at91sam926x_time.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/arch/arm/mach-at91/at91sam926x_time.c 
b/arch/arm/mach-at91/at91sam926x_time.c
index 0f04ffe9c5a8..f060f6371392 100644
--- a/arch/arm/mach-at91/at91sam926x_time.c
+++ b/arch/arm/mach-at91/at91sam926x_time.c
@@ -250,6 +250,8 @@ void __init at91sam926x_pit_init(void)
if (IS_ERR(mck))
panic(AT91: PIT: Unable to get mck clk\n);
pit_rate = clk_get_rate(mck) / 16;
+   if (pit_rate == 0)
+   panic(AT91: PIT: can't continue, mck rate is zero\n);
pit_cycle = (pit_rate + HZ/2) / HZ;
WARN_ON(((pit_cycle - 1)  ~AT91_PIT_PIV) != 0);
 
-- 
1.8.3.2

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH] Documentation: dt: list all compatible strings for at91

2014-03-20 Thread Alexandre Belloni
Hi Rob,

On 19/03/2014 at 11:14:43 -0500, Rob Herring wrote :
 On Wed, Mar 19, 2014 at 5:26 AM, Alexandre Belloni
 alexandre.bell...@free-electrons.com wrote:
  Avoids getting the newly introduced warning:
  WARNING: DT compatible string atmel,at91sam9g45-adc appears un-documented 
  -- check ./Documentation/devicetree/bindings/
  +   compatible = atmel,at91sam9g45-adc;
 
  Introduced by:
  bff5da433525 checkpatch: add DT compatible string documentation checks
 
 We should fix checkpatch instead. There are some fixes in progress,
 but I don't think it covers this issue. I'm puzzled by this one as I
 thought I checked for this case.
 

Will someone take care of it ? I'm not sure how you want to handle that
as chip is replacing different values depending on the context. Also,
while for atmel and freescale, it is replacing the full chip name, that
is not the case for nvidia...

-- 
Alexandre Belloni, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH] ARM: at91: panic when the mck rate is zero

2014-03-20 Thread Alexandre Belloni
On 20/03/2014 at 17:34:09 +0100, Boris BREZILLON wrote :
 Le 20/03/2014 17:14, Alexandre Belloni a écrit :
 If the mck rate is zero, we'll hit the following warning:
 
 WARNING: CPU: 0 PID: 0 at arch/arm/mach-at91/at91sam926x_time.c:257 
 at91sam926x_pit_init+0x13c/0x260()
 
 But the kernel will continue to try booting and face a lot of divisions by 
 zero
 when trying to handle the various clocks.
 
 Signed-off-by: Alexandre Belloni alexandre.bell...@free-electrons.com
 ---
   arch/arm/mach-at91/at91sam926x_time.c | 2 ++
   1 file changed, 2 insertions(+)
 
 diff --git a/arch/arm/mach-at91/at91sam926x_time.c 
 b/arch/arm/mach-at91/at91sam926x_time.c
 index 0f04ffe9c5a8..f060f6371392 100644
 --- a/arch/arm/mach-at91/at91sam926x_time.c
 +++ b/arch/arm/mach-at91/at91sam926x_time.c
 @@ -250,6 +250,8 @@ void __init at91sam926x_pit_init(void)
  if (IS_ERR(mck))
  panic(AT91: PIT: Unable to get mck clk\n);
  pit_rate = clk_get_rate(mck) / 16;
 +if (pit_rate == 0)
 +panic(AT91: PIT: can't continue, mck rate is zero\n);
 You're testing pit_rate why not printing:
 
 AT91: PIT: can't continue, *pit* rate is zero\n
 

pit_rate is zero because mck is zero I just didn't want to introduce a
new variable or another call to clk_get_rate(mck). I don't have any
strong opinion about that either so I can definitely make that change.


-- 
Alexandre Belloni, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH 1/2] ARM: berlin: add scu and chipctrl device nodes for BG2/BG2Q

2014-03-20 Thread Alexandre Belloni
On 20/03/2014 at 21:39:45 +0100, Sebastian Hesselbarth wrote :
 This adds scu and general purpose registers device nodes required for
 SMP on Berlin BG2 and BG2Q SoCs. The secondary CPUs will pick their jump
 address from general purpose (SW generic) register 1.
 
 Signed-off-by: Sebastian Hesselbarth sebastian.hesselba...@gmail.com

Acked-by: Alexandre Belloni alexandre.bell...@free-electrons.com

 ---
 Cc: Rob Herring robh...@kernel.org
 Cc: Pawel Moll pawel.m...@arm.com
 Cc: Mark Rutland mark.rutl...@arm.com
 Cc: Ian Campbell ijc+devicet...@hellion.org.uk
 Cc: Kumar Gala ga...@codeaurora.org
 Cc: Russell King li...@arm.linux.org.uk
 Cc: Antoine Tenart antoine.ten...@free-electrons.com
 Cc: Alexandre Belloni alexandre.bell...@free-electrons.com
 Cc: devicet...@vger.kernel.org
 Cc: linux-arm-ker...@lists.infradead.org
 Cc: linux-kernel@vger.kernel.org
 ---
  arch/arm/boot/dts/berlin2.dtsi  | 10 ++
  arch/arm/boot/dts/berlin2q.dtsi | 10 ++
  2 files changed, 20 insertions(+)
 
 diff --git a/arch/arm/boot/dts/berlin2.dtsi b/arch/arm/boot/dts/berlin2.dtsi
 index 56a1af2f1052..4d85312dc17a 100644
 --- a/arch/arm/boot/dts/berlin2.dtsi
 +++ b/arch/arm/boot/dts/berlin2.dtsi
 @@ -72,6 +72,11 @@
   cache-level = 2;
   };
  
 + scu: snoop-control-unit@ad {
 + compatible = arm,cortex-a9-scu;
 + reg = 0xad 0x58;
 + };
 +
   gic: interrupt-controller@ad1000 {
   compatible = arm,cortex-a9-gic;
   reg = 0xad1000 0x1000, 0xad0100 0x0100;
 @@ -176,6 +181,11 @@
   };
   };
  
 + generic-regs@ea0184 {
 + compatible = marvell,berlin-generic-regs, syscon;
 + reg = 0xea0184 0x10;
 + };
 +
   apb@fc {
   compatible = simple-bus;
   #address-cells = 1;
 diff --git a/arch/arm/boot/dts/berlin2q.dtsi b/arch/arm/boot/dts/berlin2q.dtsi
 index 07452a7483fa..86d8a2c49f38 100644
 --- a/arch/arm/boot/dts/berlin2q.dtsi
 +++ b/arch/arm/boot/dts/berlin2q.dtsi
 @@ -87,6 +87,11 @@
   cache-level = 2;
   };
  
 + scu: snoop-control-unit@ad {
 + compatible = arm,cortex-a9-scu;
 + reg = 0xad 0x58;
 + };
 +
   local-timer@ad0600 {
   compatible = arm,cortex-a9-twd-timer;
   reg = 0xad0600 0x20;
 @@ -183,6 +188,11 @@
   };
   };
  
 + generic-regs@ea0110 {
 + compatible = marvell,berlin-generic-regs, syscon;
 + reg = 0xea0110 0x10;
 + };
 +
   apb@fc {
   compatible = simple-bus;
   #address-cells = 1;
 -- 
 1.9.0
 

-- 
Alexandre Belloni, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH 2/2] ARM: berlin: add SMP support

2014-03-20 Thread Alexandre Belloni
On 20/03/2014 at 21:39:46 +0100, Sebastian Hesselbarth wrote :
 This adds SMP support to Marvell Berlin2 SoCs. Secondary CPUs boot into
 BootROM, wait for interrupt, and read SW generic register 1 with actual
 boot code address. Synchronization by holding pen is copied from
 plat-versatile and mach-prima2.
 
 Signed-off-by: Sebastian Hesselbarth sebastian.hesselba...@gmail.com

Acked-by: Alexandre Belloni alexandre.bell...@free-electrons.com

 ---
 Cc: Russell King li...@arm.linux.org.uk
 Cc: Antoine Tenart antoine.ten...@free-electrons.com
 Cc: Alexandre Belloni alexandre.bell...@free-electrons.com
 Cc: linux-arm-ker...@lists.infradead.org
 Cc: linux-kernel@vger.kernel.org
 ---
  arch/arm/mach-berlin/Kconfig   |   1 +
  arch/arm/mach-berlin/Makefile  |   1 +
  arch/arm/mach-berlin/berlin.c  |   3 +
  arch/arm/mach-berlin/common.h  |  18 ++
  arch/arm/mach-berlin/headsmp.S |  43 +
  arch/arm/mach-berlin/platsmp.c | 139 
 +
  6 files changed, 205 insertions(+)
  create mode 100644 arch/arm/mach-berlin/common.h
  create mode 100644 arch/arm/mach-berlin/headsmp.S
  create mode 100644 arch/arm/mach-berlin/platsmp.c
 
 diff --git a/arch/arm/mach-berlin/Kconfig b/arch/arm/mach-berlin/Kconfig
 index 7a02d222c378..eecec99c3096 100644
 --- a/arch/arm/mach-berlin/Kconfig
 +++ b/arch/arm/mach-berlin/Kconfig
 @@ -15,6 +15,7 @@ config MACH_BERLIN_BG2
   bool Marvell Armada 1500 (BG2)
   select CACHE_L2X0
   select CPU_PJ4B
 + select HAVE_ARM_SCU if SMP
   select HAVE_ARM_TWD if SMP
   select HAVE_SMP
  
 diff --git a/arch/arm/mach-berlin/Makefile b/arch/arm/mach-berlin/Makefile
 index ab69fe956f49..e11b1b0be4dd 100644
 --- a/arch/arm/mach-berlin/Makefile
 +++ b/arch/arm/mach-berlin/Makefile
 @@ -1 +1,2 @@
  obj-y += berlin.o
 +obj-$(CONFIG_SMP)+= platsmp.o headsmp.o
 diff --git a/arch/arm/mach-berlin/berlin.c b/arch/arm/mach-berlin/berlin.c
 index 025bcb5473eb..1bbca793174d 100644
 --- a/arch/arm/mach-berlin/berlin.c
 +++ b/arch/arm/mach-berlin/berlin.c
 @@ -18,6 +18,8 @@
  #include asm/hardware/cache-l2x0.h
  #include asm/mach/arch.h
  
 +#include common.h
 +
  static void __init berlin_init_machine(void)
  {
   /*
 @@ -36,4 +38,5 @@ static const char * const berlin_dt_compat[] = {
  DT_MACHINE_START(BERLIN_DT, Marvell Berlin)
   .dt_compat  = berlin_dt_compat,
   .init_machine   = berlin_init_machine,
 + .smp= smp_ops(berlin_smp_ops),
  MACHINE_END
 diff --git a/arch/arm/mach-berlin/common.h b/arch/arm/mach-berlin/common.h
 new file mode 100644
 index ..57c97669af0a
 --- /dev/null
 +++ b/arch/arm/mach-berlin/common.h
 @@ -0,0 +1,18 @@
 +/*
 + * Marvell Berlin SoCs common include.
 + *
 + * Sebastian Hesselbarth sebastian.hesselba...@gmail.com
 + *
 + * This file is licensed under the terms of the GNU General Public
 + * License version 2.  This program is licensed as is without any
 + * warranty of any kind, whether express or implied.
 + */
 +
 +#ifndef __ARCH_BERLIN_COMMON_H
 +#define __ARCH_BERLIN_COMMON_H
 +
 +extern void berlin_secondary_startup(void);
 +
 +extern struct smp_operations berlin_smp_ops;
 +
 +#endif
 diff --git a/arch/arm/mach-berlin/headsmp.S b/arch/arm/mach-berlin/headsmp.S
 new file mode 100644
 index ..bd187257fefd
 --- /dev/null
 +++ b/arch/arm/mach-berlin/headsmp.S
 @@ -0,0 +1,43 @@
 +/*
 + * linux/arch/arm/mach-berlin/headsmp.S
 + *
 + * Based on linux/arch/arm/mach-prima2/headsmp.S
 + *
 + * Copyright (c) 2003 ARM Limited
 + * All Rights Reserved
 + *
 + * 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.
 + */
 +#include linux/linkage.h
 +#include linux/init.h
 +#include asm/assembler.h
 +
 +/*
 + * Entry point for secondary CPUs, this provides a holding pen into which
 + * all secondary cores are held until we're ready for them to initialise.
 + */
 +ENTRY(berlin_secondary_startup)
 + ARM_BE8(setend be)
 + bl  v7_invalidate_l1
 + mrc p15, 0, r0, c0, c0, 5
 + and r0, r0, #15
 + adr r4, 1f
 + ldmia   r4, {r5, r6}
 + sub r4, r4, r5
 + add r6, r6, r4
 +pen: ldr r7, [r6]
 + cmp r7, r0
 + bne pen
 +
 + /*
 +  * we've been released from the holding pen: secondary_stack
 +  * should now contain the SVC stack for this core
 +  */
 + b   secondary_startup
 +ENDPROC(berlin_secondary_startup)
 +
 + .align
 +1:   .long   .
 + .long   pen_release
 diff --git a/arch/arm/mach-berlin/platsmp.c b/arch/arm/mach-berlin/platsmp.c
 new file mode 100644
 index ..5c83941b0918
 --- /dev/null
 +++ b/arch/arm/mach-berlin/platsmp.c
 @@ -0,0 +1,139 @@
 +/*
 + * linux/arch/arm/mach-berlin/platsmp.c
 + *
 + * Based on linux/arch/arm/plat-versatile/platsmp.c
 + *
 + * Copyright (C) 2002 ARM Ltd.
 + * All Rights Reserved

Re: [PATCH] Documentation: dt: list all compatible strings for at91

2014-03-21 Thread Alexandre Belloni
Hi,

On 20/03/2014 at 17:21:00 +0100, Alexandre Belloni wrote :
 Hi Rob,
 
 On 19/03/2014 at 11:14:43 -0500, Rob Herring wrote :
  On Wed, Mar 19, 2014 at 5:26 AM, Alexandre Belloni
  alexandre.bell...@free-electrons.com wrote:
   Avoids getting the newly introduced warning:
   WARNING: DT compatible string atmel,at91sam9g45-adc appears 
   un-documented -- check ./Documentation/devicetree/bindings/
   +   compatible = atmel,at91sam9g45-adc;
  
   Introduced by:
   bff5da433525 checkpatch: add DT compatible string documentation checks
  
  We should fix checkpatch instead. There are some fixes in progress,
  but I don't think it covers this issue. I'm puzzled by this one as I
  thought I checked for this case.
  
 
 Will someone take care of it ? I'm not sure how you want to handle that
 as chip is replacing different values depending on the context. Also,
 while for atmel and freescale, it is replacing the full chip name, that
 is not the case for nvidia...
 

Also, I found that naughty one:
WARNING: DT compatible string vendor fixed-clock appears un-documented -- 
check ./Documentation/devicetree/bindings/vendor-prefixes.txt

and

WARNING: DT compatible string vendor fixed-factor-clock appears un-documented 
-- check ./Documentation/devicetree/bindings/vendor-prefixes.txt

-- 
Alexandre Belloni, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 5/5] ARM: berlin/dt: add cpupll and syspll support to BG2

2014-03-21 Thread Alexandre Belloni
This also moves the clocks from the clocks container node to the root.

Signed-off-by: Alexandre Belloni alexandre.bell...@free-electrons.com
---
 arch/arm/boot/dts/berlin2.dtsi | 56 +-
 1 file changed, 39 insertions(+), 17 deletions(-)

diff --git a/arch/arm/boot/dts/berlin2.dtsi b/arch/arm/boot/dts/berlin2.dtsi
index 56a1af2f1052..4b82076ef1ed 100644
--- a/arch/arm/boot/dts/berlin2.dtsi
+++ b/arch/arm/boot/dts/berlin2.dtsi
@@ -37,24 +37,46 @@
};
};
 
-   clocks {
-   smclk: sysmgr-clock {
-   compatible = fixed-clock;
-   #clock-cells = 0;
-   clock-frequency = 2500;
-   };
+   smclk: sysmgr-clock {
+   compatible = fixed-clock;
+   #clock-cells = 0;
+   clock-frequency = 2500;
+   };
 
-   cfgclk: cfg-clock {
-   compatible = fixed-clock;
-   #clock-cells = 0;
-   clock-frequency = 1;
-   };
+   cfgclk: cfg-clock {
+   compatible = fixed-clock;
+   #clock-cells = 0;
+   clock-frequency = 1;
+   };
 
-   sysclk: system-clock {
-   compatible = fixed-clock;
-   #clock-cells = 0;
-   clock-frequency = 4;
-   };
+   syspll: syspll {
+   compatible = marvell,berlin2-pll;
+   clocks = smclk;
+   #clock-cells = 0;
+   reg = 0xf7ea0014 8;
+   };
+
+   cpupll: cpupll {
+   compatible = marvell,berlin2-pll;
+   clocks = smclk;
+   #clock-cells = 0;
+   reg = 0xf7ea003c 8;
+   };
+
+   cpuclk: cpu-clock {
+   compatible = fixed-factor-clock;
+   clocks = cpupll;
+   #clock-cells = 0;
+   clock-div = 1;
+   clock-mult = 1;
+   };
+
+   twdclk: twdclk {
+   compatible = fixed-factor-clock;
+   #clock-cells = 0;
+   clocks = cpuclk;
+   clock-mult = 1;
+   clock-div = 3;
};
 
soc {
@@ -83,7 +105,7 @@
compatible = arm,cortex-a9-twd-timer;
reg = 0xad0600 0x20;
interrupts = GIC_PPI 13 IRQ_TYPE_LEVEL_HIGH;
-   clocks = sysclk;
+   clocks = twdclk;
};
 
apb@e8 {
-- 
1.8.3.2

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 4/5] ARM: berlin/dt: add cpupll and syspll support to BG2CD

2014-03-21 Thread Alexandre Belloni
This also moves the clocks from the clocks container node to the root.

Signed-off-by: Alexandre Belloni alexandre.bell...@free-electrons.com
---
 arch/arm/boot/dts/berlin2cd.dtsi | 56 
 1 file changed, 39 insertions(+), 17 deletions(-)

diff --git a/arch/arm/boot/dts/berlin2cd.dtsi b/arch/arm/boot/dts/berlin2cd.dtsi
index 094968c27533..c84013c1597c 100644
--- a/arch/arm/boot/dts/berlin2cd.dtsi
+++ b/arch/arm/boot/dts/berlin2cd.dtsi
@@ -30,24 +30,46 @@
};
};
 
-   clocks {
-   smclk: sysmgr-clock {
-   compatible = fixed-clock;
-   #clock-cells = 0;
-   clock-frequency = 2500;
-   };
+   smclk: sysmgr-clock {
+   compatible = fixed-clock;
+   #clock-cells = 0;
+   clock-frequency = 2500;
+   };
 
-   cfgclk: cfg-clock {
-   compatible = fixed-clock;
-   #clock-cells = 0;
-   clock-frequency = 7500;
-   };
+   cfgclk: cfg-clock {
+   compatible = fixed-clock;
+   #clock-cells = 0;
+   clock-frequency = 7500;
+   };
 
-   sysclk: system-clock {
-   compatible = fixed-clock;
-   #clock-cells = 0;
-   clock-frequency = 3;
-   };
+   syspll: syspll {
+   compatible = marvell,berlin2-pll;
+   clocks = smclk;
+   #clock-cells = 0;
+   reg = 0xf7ea0014 8;
+   };
+
+   cpupll: cpupll {
+   compatible = marvell,berlin2-pll;
+   clocks = smclk;
+   #clock-cells = 0;
+   reg = 0xf7ea003c 8;
+   };
+
+   cpuclk: cpu-clock {
+   compatible = fixed-factor-clock;
+   clocks = cpupll;
+   #clock-cells = 0;
+   clock-div = 1;
+   clock-mult = 1;
+   };
+
+   twdclk: twdclk {
+   compatible = fixed-factor-clock;
+   #clock-cells = 0;
+   clocks = cpuclk;
+   clock-mult = 1;
+   clock-div = 3;
};
 
soc {
@@ -76,7 +98,7 @@
compatible = arm,cortex-a9-twd-timer;
reg = 0xad0600 0x20;
interrupts = GIC_PPI 13 IRQ_TYPE_LEVEL_HIGH;
-   clocks = sysclk;
+   clocks = twdclk;
};
 
apb@e8 {
-- 
1.8.3.2

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 1/5] clk: berlin: add support for berlin plls

2014-03-21 Thread Alexandre Belloni
This drivers allows to provide DT clocks for the cpu and system PLLs found on
Marvell Berlin SoCs.

Signed-off-by: Alexandre Belloni alexandre.bell...@free-electrons.com
---
 drivers/clk/Makefile  |   1 +
 drivers/clk/berlin/Makefile   |   1 +
 drivers/clk/berlin/clk.h  |  35 +
 drivers/clk/berlin/pll-berlin2.c  |  41 
 drivers/clk/berlin/pll-berlin2q.c |  41 
 drivers/clk/berlin/pll.c  | 100 ++
 6 files changed, 219 insertions(+)
 create mode 100644 drivers/clk/berlin/Makefile
 create mode 100644 drivers/clk/berlin/clk.h
 create mode 100644 drivers/clk/berlin/pll-berlin2.c
 create mode 100644 drivers/clk/berlin/pll-berlin2q.c
 create mode 100644 drivers/clk/berlin/pll.c

diff --git a/drivers/clk/Makefile b/drivers/clk/Makefile
index a367a9831717..4a2602737c27 100644
--- a/drivers/clk/Makefile
+++ b/drivers/clk/Makefile
@@ -29,6 +29,7 @@ obj-$(CONFIG_ARCH_VT8500) += clk-vt8500.o
 obj-$(CONFIG_COMMON_CLK_WM831X)+= clk-wm831x.o
 obj-$(CONFIG_COMMON_CLK_XGENE) += clk-xgene.o
 obj-$(CONFIG_COMMON_CLK_AT91)  += at91/
+obj-$(CONFIG_ARCH_BERLIN)  += berlin/
 obj-$(CONFIG_ARCH_HI3xxx)  += hisilicon/
 obj-$(CONFIG_COMMON_CLK_KEYSTONE)  += keystone/
 ifeq ($(CONFIG_COMMON_CLK), y)
diff --git a/drivers/clk/berlin/Makefile b/drivers/clk/berlin/Makefile
new file mode 100644
index ..4f6580e2a3ee
--- /dev/null
+++ b/drivers/clk/berlin/Makefile
@@ -0,0 +1 @@
+obj-y += pll.o pll-berlin2.o pll-berlin2q.o
diff --git a/drivers/clk/berlin/clk.h b/drivers/clk/berlin/clk.h
new file mode 100644
index ..41459db31a02
--- /dev/null
+++ b/drivers/clk/berlin/clk.h
@@ -0,0 +1,35 @@
+/*
+ * Copyright (c) 2013 Marvell Technology Group Ltd.
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms and conditions of the GNU General Public License,
+ * version 2, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
+ * more details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * this program.  If not, see http://www.gnu.org/licenses/.
+ */
+#ifndef __BERLIN_CLK_H
+#define __BERLIN_CLK_H
+
+#include linux/clk-provider.h
+
+struct berlin_pllmap {
+   const u8*vcodiv;
+   u32 fbdiv_mask;
+   u32 rfdiv_mask;
+   u32 divsel_mask;
+   u8  fbdiv_shift;
+   u8  rfdiv_shift;
+   u8  divsel_shift;
+   u8  mult;
+};
+
+extern void __init berlin_pll_setup(struct device_node *np,
+   struct berlin_pllmap *map);
+
+#endif /* BERLIN_CLK_H */
diff --git a/drivers/clk/berlin/pll-berlin2.c b/drivers/clk/berlin/pll-berlin2.c
new file mode 100644
index ..5f5b4674f811
--- /dev/null
+++ b/drivers/clk/berlin/pll-berlin2.c
@@ -0,0 +1,41 @@
+/*
+ * Copyright (c) 2014 Marvell Technology Group Ltd.
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms and conditions of the GNU General Public License,
+ * version 2, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
+ * more details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * this program.  If not, see http://www.gnu.org/licenses/.
+ */
+#include linux/io.h
+#include linux/of.h
+#include linux/kernel.h
+#include linux/clk-provider.h
+
+#include clk.h
+
+static const u8 vcodiv_berlin2[] = {10, 15, 20, 25, 30, 40, 50, 60, 80};
+
+static struct berlin_pllmap berlin_pll_map = {
+   .vcodiv = vcodiv_berlin2,
+   .fbdiv_mask = 0x1FF,
+   .rfdiv_mask = 0x1F,
+   .divsel_mask = 0xF,
+   .fbdiv_shift = 6,
+   .rfdiv_shift = 1,
+   .divsel_shift = 7,
+   .mult = 10,
+};
+
+static void __init berlin2_pll_setup(struct device_node *np)
+{
+   berlin_pll_setup(np, berlin_pll_map);
+}
+CLK_OF_DECLARE(berlin2q_pll, marvell,berlin2-pll, berlin2_pll_setup);
+
diff --git a/drivers/clk/berlin/pll-berlin2q.c 
b/drivers/clk/berlin/pll-berlin2q.c
new file mode 100644
index ..8ddfa69cf8c4
--- /dev/null
+++ b/drivers/clk/berlin/pll-berlin2q.c
@@ -0,0 +1,41 @@
+/*
+ * Copyright (c) 2013 Marvell Technology Group Ltd.
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms and conditions of the GNU General Public License,
+ * version 2, as published by the Free Software

[PATCH 3/5] ARM: berlin/dt: add cpupll and syspll support to BG2Q

2014-03-21 Thread Alexandre Belloni
Signed-off-by: Alexandre Belloni alexandre.bell...@free-electrons.com
---
 arch/arm/boot/dts/berlin2q.dtsi | 20 ++--
 1 file changed, 18 insertions(+), 2 deletions(-)

diff --git a/arch/arm/boot/dts/berlin2q.dtsi b/arch/arm/boot/dts/berlin2q.dtsi
index 07452a7483fa..19d2c82b0664 100644
--- a/arch/arm/boot/dts/berlin2q.dtsi
+++ b/arch/arm/boot/dts/berlin2q.dtsi
@@ -59,10 +59,26 @@
clock-frequency = 1;
};
 
+   syspll: syspll {
+   compatible = marvell,berlin2q-pll;
+   clocks = smclk;
+   #clock-cells = 0;
+   reg = 0xf7ea0030 8;
+   };
+
+   cpupll: cpupll {
+   compatible = marvell,berlin2q-pll;
+   clocks = smclk;
+   #clock-cells = 0;
+   reg = 0xf7dd0170 8;
+   };
+
cpuclk: cpu-clock {
-   compatible = fixed-clock;
+   compatible = fixed-factor-clock;
+   clocks = cpupll;
#clock-cells = 0;
-   clock-frequency = 12;
+   clock-div = 1;
+   clock-mult = 1;
};
 
twdclk: twdclk {
-- 
1.8.3.2

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 0/5] berlin: initial support for the clocks

2014-03-21 Thread Alexandre Belloni
This series adds support for the berlin PLLs. This allows to remove the bogus
fixed clocks that are used in the SoCs dts includes.

For now, I have left out the AVPLL to ease reviewing.

This is tested on a BG2Q DMP.

Alexandre Belloni (5):
  clk: berlin: add support for berlin plls
  clk: berlin: add berlin clocks DT bindings documentation
  ARM: berlin/dt: add cpupll and syspll support to BG2Q
  ARM: berlin/dt: add cpupll and syspll support to BG2CD
  ARM: berlin/dt: add cpupll and syspll support to BG2

 .../devicetree/bindings/clock/berlin-clock.txt |  29 ++
 arch/arm/boot/dts/berlin2.dtsi |  56 
 arch/arm/boot/dts/berlin2cd.dtsi   |  56 
 arch/arm/boot/dts/berlin2q.dtsi|  20 -
 drivers/clk/Makefile   |   1 +
 drivers/clk/berlin/Makefile|   1 +
 drivers/clk/berlin/clk.h   |  35 
 drivers/clk/berlin/pll-berlin2.c   |  41 +
 drivers/clk/berlin/pll-berlin2q.c  |  41 +
 drivers/clk/berlin/pll.c   | 100 +
 10 files changed, 344 insertions(+), 36 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/clock/berlin-clock.txt
 create mode 100644 drivers/clk/berlin/Makefile
 create mode 100644 drivers/clk/berlin/clk.h
 create mode 100644 drivers/clk/berlin/pll-berlin2.c
 create mode 100644 drivers/clk/berlin/pll-berlin2q.c
 create mode 100644 drivers/clk/berlin/pll.c

-- 
1.8.3.2

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 2/5] clk: berlin: add berlin clocks DT bindings documentation

2014-03-21 Thread Alexandre Belloni
Cc: devicet...@vger.kernel.org
Signed-off-by: Alexandre Belloni alexandre.bell...@free-electrons.com
---
 .../devicetree/bindings/clock/berlin-clock.txt | 29 ++
 1 file changed, 29 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/clock/berlin-clock.txt

diff --git a/Documentation/devicetree/bindings/clock/berlin-clock.txt 
b/Documentation/devicetree/bindings/clock/berlin-clock.txt
new file mode 100644
index ..ebc78f9b93a9
--- /dev/null
+++ b/Documentation/devicetree/bindings/clock/berlin-clock.txt
@@ -0,0 +1,29 @@
+Device Tree Clock bindings for Marvell Berlin clocks
+
+This binding uses the common clock binding[1].
+
+[1] Documentation/devicetree/bindings/clock/clock-bindings.txt
+
+Required properties:
+- compatible : shall be one of the following:
+   marvell,berlin2-pll or
+   marvell,berlin2q-pll:
+   CPU PLL and System PLL
+- reg : Address and length of the clock register set.
+- #clock-cells : from common clock binding; shall be set to 0.
+- clocks : shall be the input parent clock phandle for the clock.
+
+smclk: sysmgr-clock {
+   compatible = fixed-clock;
+   #clock-cells = 0;
+   clock-frequency = 2500;
+};
+
+cpupll: cpupll {
+   compatible = marvell,berlin2-pll;
+   clocks = smclk;
+   #clock-cells = 0;
+   reg = 0xf7ea003c 8;
+};
+
+
-- 
1.8.3.2

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH 3/5] ARM: berlin/dt: add cpupll and syspll support to BG2Q

2014-03-21 Thread Alexandre Belloni
On 21/03/2014 at 13:11:29 +0100, Sebastian Hesselbarth wrote :
 On 03/21/2014 12:43 PM, Alexandre Belloni wrote:
 
 Alexandre,
 
 Thanks for starting this! I'll start with the most obvious
 things first and have a closer look on it later.
 

I will rework and wait for your other comments before sending a new
version. BTW, I've set up a branch on github if you want to try on your
platforms:

https://github.com/alexandrebelloni/linux.git topic/berlin-clk

 Missing commit description here.
 
 Signed-off-by: Alexandre Belloni alexandre.bell...@free-electrons.com
 ---
   arch/arm/boot/dts/berlin2q.dtsi | 20 ++--
   1 file changed, 18 insertions(+), 2 deletions(-)
 
 diff --git a/arch/arm/boot/dts/berlin2q.dtsi 
 b/arch/arm/boot/dts/berlin2q.dtsi
 index 07452a7483fa..19d2c82b0664 100644
 --- a/arch/arm/boot/dts/berlin2q.dtsi
 +++ b/arch/arm/boot/dts/berlin2q.dtsi
 @@ -59,10 +59,26 @@
  clock-frequency = 1;
  };
 
 +syspll: syspll {
 
 syspll: pll@ea0030 {
 
 and sort it in between other SoC nodes below. This will
 most likely break clocks in v3.14 but v3.15 will receive
 proper clock init ordering.
 

I will do across all the dtsi, don't bother repeating yourself :)

 +compatible = marvell,berlin2q-pll;
 +clocks = smclk;
 +#clock-cells = 0;
 +reg = 0xf7ea0030 8;
 +};
 +
 +cpupll: cpupll {
 
 dito.
 
 +compatible = marvell,berlin2q-pll;
 +clocks = smclk;
 +#clock-cells = 0;
 +reg = 0xf7dd0170 8;
 +};
 +
  cpuclk: cpu-clock {
 -compatible = fixed-clock;
 +compatible = fixed-factor-clock;
 +clocks = cpupll;
  #clock-cells = 0;
 -clock-frequency = 12;
 +clock-div = 1;
 +clock-mult = 1;
 
 Hmm, you probably know better than me, but if cpuclk == cpupll
 is always true we don't need another clk layer here. If you
 can scale down cpuclk from cpupll and we just have no driver
 for it, I am fine with it.
 

You can actually switch CPU clk from CPU pll to smclk. I'm not sure this
is completely useful yet though, probably for suspend ?

Also, while I'm not sure this is a good reason, other clocks are derived
from CPU pll and have another divider.


-- 
Alexandre Belloni, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH 3/5] ARM: berlin/dt: add cpupll and syspll support to BG2Q

2014-03-21 Thread Alexandre Belloni
On 21/03/2014 at 13:29:31 +0100, Sebastian Hesselbarth wrote :
 Hmm, you probably know better than me, but if cpuclk == cpupll
 is always true we don't need another clk layer here. If you
 can scale down cpuclk from cpupll and we just have no driver
 for it, I am fine with it.
 
 
 You can actually switch CPU clk from CPU pll to smclk. I'm not sure this
 is completely useful yet though, probably for suspend ?
 
 Then it should be clk mux instead?
 
 Also, while I'm not sure this is a good reason, other clocks are derived
 from CPU pll and have another divider.
 
 I have no strong opinion, but a fixed-factor-clock with 1:1 just to
 rename cpupll to cpuclk seems a bit wasty ;)
 
 If there is a mux, we should add it now - no matter if we are ever
 going to make any use of it. For the derived clocks we should be
 careful if they actually depend on cpuclk or always cpupll.
 
 If your (current) knowledge of the berlin clock trees is almost as
 bad as mine, we can also ignore cpuclk mux if you prefer.
 

Yeah, fact is I know there is a mux but I don't know yet how to get/set
its state so I will ignore it until we have more info.

-- 
Alexandre Belloni, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH 1/5] clk: berlin: add support for berlin plls

2014-03-21 Thread Alexandre Belloni
[all commentis I agree on are snipped]

On 21/03/2014 at 13:49:32 +0100, Sebastian Hesselbarth wrote :
 On 03/21/2014 12:43 PM, Alexandre Belloni wrote:
 obj-y += pll.o
 obj-$(CONFIG_MACH_BERLIN_BG2) += pll-berlin2.o
 obj-$(CONFIG_MACH_BERLIN_BG2CD)   += pll-berlin2.o
 obj-$(CONFIG_MACH_BERLIN_BG2Q)+= pll-berlin2q.o
 
 Which reminds me, that we forgot to add MACH_BERLIN_BG2Q to
 arch/arm/mach-berlin/Kconfig. Can you spin a patch?
 

I will do that.

 +static const u8 vcodiv_berlin2[] = {10, 15, 20, 25, 30, 40, 50, 60, 80};
 +
 +static struct berlin_pllmap berlin_pll_map = {
 +.vcodiv = vcodiv_berlin2,
 +.fbdiv_mask = 0x1FF,
 +.rfdiv_mask = 0x1F,
 +.divsel_mask = 0xF,
 
 divsel_mask allows 16 possible values, vcodiv_berlin2[] only provides
 9, and common pll driver below does not know how many valid vcodiv
 values are passed. That can become dangerous..
 
 I'd rather extend vcodiv_berlin2 to full divsel range and provide
 safe (=1) divisiors. This way wrong/new register values will only
 break clock frequency derived.
 

Good catch ! Then, what about simply shrinking the mask so that we don't
overflow the table. We'll put it back to its supposed real value whant
we know what are the remaining divisors (my guess is that they are already
all listed here). I would say that we are getting the divisor wrong if
divsel  8 anyway.

 +.fbdiv_shift = 6,
 +.rfdiv_shift = 1,
 +.divsel_shift = 7,
 
 Have .foo_mask and .foo_shift together?
 

This will make the struct larger but I don't really have an opinion.


-- 
Alexandre Belloni, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH 1/5] clk: berlin: add support for berlin plls

2014-03-21 Thread Alexandre Belloni
On 21/03/2014 at 13:49:32 +0100, Sebastian Hesselbarth wrote :
 On 03/21/2014 12:43 PM, Alexandre Belloni wrote:
 diff --git a/drivers/clk/Makefile b/drivers/clk/Makefile
 index a367a9831717..4a2602737c27 100644
 --- a/drivers/clk/Makefile
 +++ b/drivers/clk/Makefile
 @@ -29,6 +29,7 @@ obj-$(CONFIG_ARCH_VT8500)  += clk-vt8500.o
   obj-$(CONFIG_COMMON_CLK_WM831X)+= clk-wm831x.o
   obj-$(CONFIG_COMMON_CLK_XGENE) += clk-xgene.o
   obj-$(CONFIG_COMMON_CLK_AT91)  += at91/
 +obj-$(CONFIG_ARCH_BERLIN)   += berlin/
   obj-$(CONFIG_ARCH_HI3xxx)  += hisilicon/
   obj-$(CONFIG_COMMON_CLK_KEYSTONE)  += keystone/
 
 I'll have a look at clk/Makefile later myself, but alphabetic ordering
 seems to be broken by ARCH_HI3xxx already. Anyway, we shouldn't just
 add another violator.
 

BTW,  don't think there is any issue here, the Makefile states:
# please keep this section sorted lexicographically by file/directory path name



-- 
Alexandre Belloni, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH 1/5] clk: berlin: add support for berlin plls

2014-03-21 Thread Alexandre Belloni
On 21/03/2014 at 16:45:39 +0100, Alexandre Belloni wrote :
  +  .fbdiv_shift = 6,
  +  .rfdiv_shift = 1,
  +  .divsel_shift = 7,
  
  Have .foo_mask and .foo_shift together?
  
 
 This will make the struct larger but I don't really have an opinion.
 

Forget that one, I'll take a break...

-- 
Alexandre Belloni, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH 1/5] clk: berlin: add support for berlin plls

2014-03-21 Thread Alexandre Belloni
On 21/03/2014 at 17:03:52 +0100, Sebastian Hesselbarth wrote :
 On 03/21/2014 04:45 PM, Alexandre Belloni wrote:
 [all commentis I agree on are snipped]
 
 :)
 
 On 21/03/2014 at 13:49:32 +0100, Sebastian Hesselbarth wrote :
 On 03/21/2014 12:43 PM, Alexandre Belloni wrote:
 obj-y += pll.o
 obj-$(CONFIG_MACH_BERLIN_BG2)   += pll-berlin2.o
 obj-$(CONFIG_MACH_BERLIN_BG2CD) += pll-berlin2.o
 obj-$(CONFIG_MACH_BERLIN_BG2Q)  += pll-berlin2q.o
 
 Which reminds me, that we forgot to add MACH_BERLIN_BG2Q to
 arch/arm/mach-berlin/Kconfig. Can you spin a patch?
 
 
 I will do that.
 
 +static const u8 vcodiv_berlin2[] = {10, 15, 20, 25, 30, 40, 50, 60, 80};
 +
 +static struct berlin_pllmap berlin_pll_map = {
 +  .vcodiv = vcodiv_berlin2,
 +  .fbdiv_mask = 0x1FF,
 +  .rfdiv_mask = 0x1F,
 +  .divsel_mask = 0xF,
 
 divsel_mask allows 16 possible values, vcodiv_berlin2[] only provides
 9, and common pll driver below does not know how many valid vcodiv
 values are passed. That can become dangerous..
 
 I'd rather extend vcodiv_berlin2 to full divsel range and provide
 safe (=1) divisiors. This way wrong/new register values will only
 break clock frequency derived.
 
 
 Good catch ! Then, what about simply shrinking the mask so that we don't
 overflow the table. We'll put it back to its supposed real value whant
 we know what are the remaining divisors (my guess is that they are already
 all listed here). I would say that we are getting the divisor wrong if
 divsel  8 anyway.
 
 Hmm, maybe I should look up valid vcodiv myself, but your vcodiv_berlin2
 has 9 values and I guess they are all valid, aren't they?
 
 The next possible, larger mask where 0-8 fits in, is 0xf. You used that
 above and that reveals 16 possible indices.
 
 The only option for shrinking the table that I see, would be min/max
 allowed indices, but that is as useful as having a slightly larger
 table.
 

You are absolutely right :) I definitely need to take a break, right now !

 +  .fbdiv_shift = 6,
 +  .rfdiv_shift = 1,
 +  .divsel_shift = 7,
 
 Have .foo_mask and .foo_shift together?
 
 
 This will make the struct larger but I don't really have an opinion.
 
 Maybe, I wasn't clear enough. Just assign .foo_mask and .foo_shift in
 subsequent lines of code, i.e.
 
 static struct berlin_pllmap berlin_pll_map = {
   .vcodiv = vcodiv_berlin2,
   .fbdiv_mask = 0x1FF,
   .fbdiv_shift = 6,
   .rfdiv_mask = 0x1F,
   .rfdiv_shift = 1,
   .divsel_mask = 0xF,
   .divsel_shift = 7,
 };
 

yeah, I figured that out a few minutes ago...

Thanks again for your reviews and patience !

-- 
Alexandre Belloni, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 2/2] ARM: multi_v7_defconfig: Select CONFIG_MACH_BERLIN_BG2Q

2014-03-21 Thread Alexandre Belloni
Now that we support Berlin BG2Q, select CONFIG_MACH_BERLIN_BG2Q so that we can
boot BG2Q based boards like the BG2Q DMP.

Signed-off-by: Alexandre Belloni alexandre.bell...@free-electrons.com
---
 arch/arm/configs/multi_v7_defconfig | 1 +
 1 file changed, 1 insertion(+)

diff --git a/arch/arm/configs/multi_v7_defconfig 
b/arch/arm/configs/multi_v7_defconfig
index ee6982976d66..8b09b72fb688 100644
--- a/arch/arm/configs/multi_v7_defconfig
+++ b/arch/arm/configs/multi_v7_defconfig
@@ -15,6 +15,7 @@ CONFIG_ARCH_BCM_MOBILE=y
 CONFIG_ARCH_BERLIN=y
 CONFIG_MACH_BERLIN_BG2=y
 CONFIG_MACH_BERLIN_BG2CD=y
+CONFIG_MACH_BERLIN_BG2Q=y
 CONFIG_GPIO_PCA953X=y
 CONFIG_ARCH_HIGHBANK=y
 CONFIG_ARCH_HI3xxx=y
-- 
1.8.3.2

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 1/2] ARM: berlin: add MACH_BERLIN_BG2Q symbol

2014-03-21 Thread Alexandre Belloni
Now that we start supporting the Marvell Berlin BG2Q, add a symbol allowing to
differentiate that SoC from the other SoCs of the Berlin family.

Signed-off-by: Alexandre Belloni alexandre.bell...@free-electrons.com
---
 arch/arm/mach-berlin/Kconfig | 7 +++
 1 file changed, 7 insertions(+)

diff --git a/arch/arm/mach-berlin/Kconfig b/arch/arm/mach-berlin/Kconfig
index 7a02d222c378..0ff6f5877076 100644
--- a/arch/arm/mach-berlin/Kconfig
+++ b/arch/arm/mach-berlin/Kconfig
@@ -24,6 +24,13 @@ config MACH_BERLIN_BG2CD
select CPU_V7
select HAVE_ARM_TWD if SMP
 
+config MACH_BERLIN_BG2Q
+   bool Marvell Armada 1500 Pro (BG2-Q)
+   select CACHE_L2X0
+   select CPU_V7
+   select HAVE_ARM_TWD if SMP
+   select HAVE_SMP
+
 endmenu
 
 endif
-- 
1.8.3.2

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH v2 1/5] clk: berlin: add support for berlin plls

2014-03-21 Thread Alexandre Belloni
This drivers allows to provide DT clocks for the cpu and system PLLs found on
Marvell Berlin SoCs.

Signed-off-by: Alexandre Belloni alexandre.bell...@free-electrons.com
---
 drivers/clk/Makefile  |   1 +
 drivers/clk/berlin/Makefile   |   4 ++
 drivers/clk/berlin/common.h   |  35 +
 drivers/clk/berlin/pll-berlin2.c  |  42 +++
 drivers/clk/berlin/pll-berlin2q.c |  42 +++
 drivers/clk/berlin/pll.c  | 107 ++
 6 files changed, 231 insertions(+)
 create mode 100644 drivers/clk/berlin/Makefile
 create mode 100644 drivers/clk/berlin/common.h
 create mode 100644 drivers/clk/berlin/pll-berlin2.c
 create mode 100644 drivers/clk/berlin/pll-berlin2q.c
 create mode 100644 drivers/clk/berlin/pll.c

diff --git a/drivers/clk/Makefile b/drivers/clk/Makefile
index a367a9831717..4a2602737c27 100644
--- a/drivers/clk/Makefile
+++ b/drivers/clk/Makefile
@@ -29,6 +29,7 @@ obj-$(CONFIG_ARCH_VT8500) += clk-vt8500.o
 obj-$(CONFIG_COMMON_CLK_WM831X)+= clk-wm831x.o
 obj-$(CONFIG_COMMON_CLK_XGENE) += clk-xgene.o
 obj-$(CONFIG_COMMON_CLK_AT91)  += at91/
+obj-$(CONFIG_ARCH_BERLIN)  += berlin/
 obj-$(CONFIG_ARCH_HI3xxx)  += hisilicon/
 obj-$(CONFIG_COMMON_CLK_KEYSTONE)  += keystone/
 ifeq ($(CONFIG_COMMON_CLK), y)
diff --git a/drivers/clk/berlin/Makefile b/drivers/clk/berlin/Makefile
new file mode 100644
index ..94859513de90
--- /dev/null
+++ b/drivers/clk/berlin/Makefile
@@ -0,0 +1,4 @@
+obj-y += pll.o
+obj-$(CONFIG_MACH_BERLIN_BG2)   += pll-berlin2.o
+obj-$(CONFIG_MACH_BERLIN_BG2CD) += pll-berlin2.o
+obj-$(CONFIG_MACH_BERLIN_BG2Q)  += pll-berlin2q.o
diff --git a/drivers/clk/berlin/common.h b/drivers/clk/berlin/common.h
new file mode 100644
index ..8eb8a9f9aa30
--- /dev/null
+++ b/drivers/clk/berlin/common.h
@@ -0,0 +1,35 @@
+/*
+ * Copyright (c) 2014 Marvell Technology Group Ltd.
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms and conditions of the GNU General Public License,
+ * version 2, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
+ * more details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * this program.  If not, see http://www.gnu.org/licenses/.
+ */
+#ifndef __BERLIN_CLK_H
+#define __BERLIN_CLK_H
+
+struct device_node;
+
+struct berlin_pllmap {
+   const u8*vcodiv;
+   u32 fbdiv_mask;
+   u32 rfdiv_mask;
+   u32 divsel_mask;
+   u8  fbdiv_shift;
+   u8  rfdiv_shift;
+   u8  divsel_shift;
+   u8  mult;
+};
+
+extern void __init berlin_pll_setup(struct device_node *np,
+   struct berlin_pllmap *map);
+
+#endif /* BERLIN_CLK_H */
diff --git a/drivers/clk/berlin/pll-berlin2.c b/drivers/clk/berlin/pll-berlin2.c
new file mode 100644
index ..3b2f5856442d
--- /dev/null
+++ b/drivers/clk/berlin/pll-berlin2.c
@@ -0,0 +1,42 @@
+/*
+ * Copyright (c) 2014 Marvell Technology Group Ltd.
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms and conditions of the GNU General Public License,
+ * version 2, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
+ * more details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * this program.  If not, see http://www.gnu.org/licenses/.
+ */
+#include linux/clk-provider.h
+#include linux/io.h
+#include linux/kernel.h
+#include linux/of.h
+
+#include common.h
+
+static const u8 vcodiv_berlin2[] = {10, 15, 20, 25, 30, 40, 50, 60, 80,
+   1, 1, 1, 1, 1, 1, 1};
+
+static struct berlin_pllmap berlin_pll_map = {
+   .vcodiv = vcodiv_berlin2,
+   .fbdiv_mask = 0x1FF,
+   .fbdiv_shift = 6,
+   .rfdiv_mask = 0x1F,
+   .rfdiv_shift = 1,
+   .divsel_mask = 0xF,
+   .divsel_shift = 7,
+   .mult = 10,
+};
+
+static void __init berlin2_pll_setup(struct device_node *np)
+{
+   berlin_pll_setup(np, berlin_pll_map);
+}
+CLK_OF_DECLARE(berlin2q_pll, marvell,berlin2-pll, berlin2_pll_setup);
+
diff --git a/drivers/clk/berlin/pll-berlin2q.c 
b/drivers/clk/berlin/pll-berlin2q.c
new file mode 100644
index ..0a2e9968cc09
--- /dev/null
+++ b/drivers/clk/berlin/pll-berlin2q.c
@@ -0,0 +1,42 @@
+/*
+ * Copyright (c) 2014 Marvell Technology Group Ltd

[PATCH v2 4/5] ARM: berlin/dt: add cpupll and syspll support to BG2CD

2014-03-21 Thread Alexandre Belloni
The Berlin BG2CD has two supported PLLs: CPU PLL and System PLL, add those to
the SoC device tree.

This also moves the remaining clocks from the clocks container node to the root.

Signed-off-by: Alexandre Belloni alexandre.bell...@free-electrons.com
---
 arch/arm/boot/dts/berlin2cd.dtsi | 48 ++--
 1 file changed, 31 insertions(+), 17 deletions(-)

diff --git a/arch/arm/boot/dts/berlin2cd.dtsi b/arch/arm/boot/dts/berlin2cd.dtsi
index 094968c27533..bd4e9dd4867e 100644
--- a/arch/arm/boot/dts/berlin2cd.dtsi
+++ b/arch/arm/boot/dts/berlin2cd.dtsi
@@ -30,24 +30,24 @@
};
};
 
-   clocks {
-   smclk: sysmgr-clock {
-   compatible = fixed-clock;
-   #clock-cells = 0;
-   clock-frequency = 2500;
-   };
+   smclk: sysmgr-clock {
+   compatible = fixed-clock;
+   #clock-cells = 0;
+   clock-frequency = 2500;
+   };
 
-   cfgclk: cfg-clock {
-   compatible = fixed-clock;
-   #clock-cells = 0;
-   clock-frequency = 7500;
-   };
+   cfgclk: cfg-clock {
+   compatible = fixed-clock;
+   #clock-cells = 0;
+   clock-frequency = 7500;
+   };
 
-   sysclk: system-clock {
-   compatible = fixed-clock;
-   #clock-cells = 0;
-   clock-frequency = 3;
-   };
+   twdclk: twdclk {
+   compatible = fixed-factor-clock;
+   #clock-cells = 0;
+   clocks = cpupll;
+   clock-mult = 1;
+   clock-div = 3;
};
 
soc {
@@ -76,7 +76,21 @@
compatible = arm,cortex-a9-twd-timer;
reg = 0xad0600 0x20;
interrupts = GIC_PPI 13 IRQ_TYPE_LEVEL_HIGH;
-   clocks = sysclk;
+   clocks = twdclk;
+   };
+
+   syspll: syspll@ea0014 {
+   compatible = marvell,berlin2-pll;
+   clocks = smclk;
+   #clock-cells = 0;
+   reg = 0xf7ea0014 8;
+   };
+
+   cpupll: cpupll@ea003c {
+   compatible = marvell,berlin2-pll;
+   clocks = smclk;
+   #clock-cells = 0;
+   reg = 0xf7ea003c 8;
};
 
apb@e8 {
-- 
1.8.3.2

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH v2 5/5] ARM: berlin/dt: add cpupll and syspll support to BG2

2014-03-21 Thread Alexandre Belloni
The Berlin BG2 has two supported PLLs: CPU PLL and System PLL, add those to the
SoC device tree.

This also moves the remaining clocks from the clocks container node to the root.

Signed-off-by: Alexandre Belloni alexandre.bell...@free-electrons.com
---
 arch/arm/boot/dts/berlin2.dtsi | 48 +++---
 1 file changed, 31 insertions(+), 17 deletions(-)

diff --git a/arch/arm/boot/dts/berlin2.dtsi b/arch/arm/boot/dts/berlin2.dtsi
index 56a1af2f1052..6c080eb6242a 100644
--- a/arch/arm/boot/dts/berlin2.dtsi
+++ b/arch/arm/boot/dts/berlin2.dtsi
@@ -37,24 +37,24 @@
};
};
 
-   clocks {
-   smclk: sysmgr-clock {
-   compatible = fixed-clock;
-   #clock-cells = 0;
-   clock-frequency = 2500;
-   };
+   smclk: sysmgr-clock {
+   compatible = fixed-clock;
+   #clock-cells = 0;
+   clock-frequency = 2500;
+   };
 
-   cfgclk: cfg-clock {
-   compatible = fixed-clock;
-   #clock-cells = 0;
-   clock-frequency = 1;
-   };
+   cfgclk: cfg-clock {
+   compatible = fixed-clock;
+   #clock-cells = 0;
+   clock-frequency = 1;
+   };
 
-   sysclk: system-clock {
-   compatible = fixed-clock;
-   #clock-cells = 0;
-   clock-frequency = 4;
-   };
+   twdclk: twdclk {
+   compatible = fixed-factor-clock;
+   #clock-cells = 0;
+   clocks = cpupll;
+   clock-mult = 1;
+   clock-div = 3;
};
 
soc {
@@ -83,7 +83,21 @@
compatible = arm,cortex-a9-twd-timer;
reg = 0xad0600 0x20;
interrupts = GIC_PPI 13 IRQ_TYPE_LEVEL_HIGH;
-   clocks = sysclk;
+   clocks = twdclk;
+   };
+
+   syspll: syspll@ea0014 {
+   compatible = marvell,berlin2-pll;
+   clocks = smclk;
+   #clock-cells = 0;
+   reg = 0xea0014 8;
+   };
+
+   cpupll: cpupll@ea003c {
+   compatible = marvell,berlin2-pll;
+   clocks = smclk;
+   #clock-cells = 0;
+   reg = 0xea003c 8;
};
 
apb@e8 {
-- 
1.8.3.2

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH v2 2/5] clk: berlin: add berlin clocks DT bindings documentation

2014-03-21 Thread Alexandre Belloni
Document the device tree bindings for the PLLs found on the Marvell Berlin SoCs.

Cc: devicet...@vger.kernel.org
Signed-off-by: Alexandre Belloni alexandre.bell...@free-electrons.com
---
 .../devicetree/bindings/clock/berlin-clock.txt | 29 ++
 1 file changed, 29 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/clock/berlin-clock.txt

diff --git a/Documentation/devicetree/bindings/clock/berlin-clock.txt 
b/Documentation/devicetree/bindings/clock/berlin-clock.txt
new file mode 100644
index ..49b7860bffb8
--- /dev/null
+++ b/Documentation/devicetree/bindings/clock/berlin-clock.txt
@@ -0,0 +1,29 @@
+Device Tree Clock bindings for Marvell Berlin clocks
+
+This binding uses the common clock binding[1].
+
+[1] Documentation/devicetree/bindings/clock/clock-bindings.txt
+
+Required properties:
+- compatible: shall be one of the following:
+   marvell,berlin2-pll,
+   marvell,berlin2q-pll:
+   CPU PLL and System PLL
+- reg: Address and length of the clock register set.
+- #clock-cells: from common clock binding; shall be set to 0.
+- clocks: from common clock binding
+
+smclk: sysmgr-clock {
+   compatible = fixed-clock;
+   #clock-cells = 0;
+   clock-frequency = 2500;
+};
+
+cpupll: cpupll@ea003c {
+   compatible = marvell,berlin2-pll;
+   clocks = smclk;
+   #clock-cells = 0;
+   reg = 0xea003c 0x8;
+};
+
+
-- 
1.8.3.2

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH v2 0/5] berlin: initial support for the clocks

2014-03-21 Thread Alexandre Belloni
This series adds support for the berlin PLLs. This allows to remove the bogus
fixed clocks that are used in the SoCs dts includes.

For now, I have left out the AVPLL to ease reviewing.

This is tested on a BG2Q DMP.

Changes in v2:
 - reworked the DT bindings documentation
 - removed the cpuclk node
 - moved the pll node in the soc node and ordered them by address.
 - renamed clk.h = common.h and removed the stray #include
 - reordered the includes in pll-*.c
 - extended the vcodiv tables so that we can't overflow it
 - reordered the struct berlin_pllmap members assignements
 - replaced the void *data member of the struct berlin_pll by a
   struct berlin_pllmap *map

Alexandre Belloni (5):
  clk: berlin: add support for berlin plls
  clk: berlin: add berlin clocks DT bindings documentation
  ARM: berlin/dt: add cpupll and syspll support to BG2Q
  ARM: berlin/dt: add cpupll and syspll support to BG2CD
  ARM: berlin/dt: add cpupll and syspll support to BG2

 .../devicetree/bindings/clock/berlin-clock.txt |  29 ++
 arch/arm/boot/dts/berlin2.dtsi |  48 +
 arch/arm/boot/dts/berlin2cd.dtsi   |  48 +
 arch/arm/boot/dts/berlin2q.dtsi|  22 +++--
 drivers/clk/Makefile   |   1 +
 drivers/clk/berlin/Makefile|   4 +
 drivers/clk/berlin/common.h|  35 +++
 drivers/clk/berlin/pll-berlin2.c   |  42 
 drivers/clk/berlin/pll-berlin2q.c  |  42 
 drivers/clk/berlin/pll.c   | 107 +
 10 files changed, 337 insertions(+), 41 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/clock/berlin-clock.txt
 create mode 100644 drivers/clk/berlin/Makefile
 create mode 100644 drivers/clk/berlin/common.h
 create mode 100644 drivers/clk/berlin/pll-berlin2.c
 create mode 100644 drivers/clk/berlin/pll-berlin2q.c
 create mode 100644 drivers/clk/berlin/pll.c

-- 
1.8.3.2

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH v2 3/5] ARM: berlin/dt: add cpupll and syspll support to BG2Q

2014-03-21 Thread Alexandre Belloni
The Berlin BG2Q has two supported PLLs: CPU PLL and System PLL, add those to the
SoC device tree.

Note that support for the AVPLL is not yet available.

Signed-off-by: Alexandre Belloni alexandre.bell...@free-electrons.com
---
 arch/arm/boot/dts/berlin2q.dtsi | 22 +++---
 1 file changed, 15 insertions(+), 7 deletions(-)

diff --git a/arch/arm/boot/dts/berlin2q.dtsi b/arch/arm/boot/dts/berlin2q.dtsi
index 07452a7483fa..5925e6a16749 100644
--- a/arch/arm/boot/dts/berlin2q.dtsi
+++ b/arch/arm/boot/dts/berlin2q.dtsi
@@ -59,16 +59,10 @@
clock-frequency = 1;
};
 
-   cpuclk: cpu-clock {
-   compatible = fixed-clock;
-   #clock-cells = 0;
-   clock-frequency = 12;
-   };
-
twdclk: twdclk {
compatible = fixed-factor-clock;
#clock-cells = 0;
-   clocks = cpuclk;
+   clocks = cpupll;
clock-mult = 1;
clock-div = 3;
};
@@ -101,6 +95,20 @@
#interrupt-cells = 3;
};
 
+   cpupll: cpupll@dd0170 {
+   compatible = marvell,berlin2q-pll;
+   clocks = smclk;
+   #clock-cells = 0;
+   reg = 0xdd0170 0x8;
+   };
+
+   syspll: syspll@ea0030 {
+   compatible = marvell,berlin2q-pll;
+   clocks = smclk;
+   #clock-cells = 0;
+   reg = 0xea0030 0x8;
+   };
+
apb@e8 {
compatible = simple-bus;
#address-cells = 1;
-- 
1.8.3.2

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH v2 4/5] ARM: berlin/dt: add cpupll and syspll support to BG2CD

2014-03-21 Thread Alexandre Belloni
On 21/03/2014 at 22:35:26 +0100, Sebastian Hesselbarth wrote :
 On 03/21/2014 09:08 PM, Alexandre Belloni wrote:
 The Berlin BG2CD has two supported PLLs: CPU PLL and System PLL, add those to
 the SoC device tree.
 
 This also moves the remaining clocks from the clocks container node to the 
 root.
 
 Signed-off-by: Alexandre Belloni alexandre.bell...@free-electrons.com
 ---
   arch/arm/boot/dts/berlin2cd.dtsi | 48 
  ++--
   1 file changed, 31 insertions(+), 17 deletions(-)
 
 diff --git a/arch/arm/boot/dts/berlin2cd.dtsi 
 b/arch/arm/boot/dts/berlin2cd.dtsi
 index 094968c27533..bd4e9dd4867e 100644
 --- a/arch/arm/boot/dts/berlin2cd.dtsi
 +++ b/arch/arm/boot/dts/berlin2cd.dtsi
 @@ -30,24 +30,24 @@
 [...]
 @@ -76,7 +76,21 @@
  compatible = arm,cortex-a9-twd-timer;
  reg = 0xad0600 0x20;
  interrupts = GIC_PPI 13 IRQ_TYPE_LEVEL_HIGH;
 -clocks = sysclk;
 +clocks = twdclk;
 +};
 +
 +syspll: syspll@ea0014 {
 +compatible = marvell,berlin2-pll;
 +clocks = smclk;
 +#clock-cells = 0;
 +reg = 0xf7ea0014 8;
 
 nit: I prefer hex numbers all over for reg properties. berlin2q already
 has them, and I'll fixup this and the one below myself.
 

Indeed, I did fix that for bg2q and documentation and forgot bg2 and
bg2cd.

 +};
 +
 +cpupll: cpupll@ea003c {
 +compatible = marvell,berlin2-pll;
 +clocks = smclk;
 +#clock-cells = 0;
 +reg = 0xf7ea003c 8;
 
 ditto.
 
 Sebastian
 
  };
 
  apb@e8 {
 
 

-- 
Alexandre Belloni, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH v2 2/5] clk: berlin: add berlin clocks DT bindings documentation

2014-03-21 Thread Alexandre Belloni
On 21/03/2014 at 22:31:09 +0100, Sebastian Hesselbarth wrote :
 On 03/21/2014 09:08 PM, Alexandre Belloni wrote:
 Document the device tree bindings for the PLLs found on the Marvell Berlin 
 SoCs.
 
 Cc: devicet...@vger.kernel.org
 
 You forgot to add Mark Rutland's Reviewed-by. He didn't mentioned it
 explicitly but his Otherwise this looks fine to me on v1, is as good
 as a Reviewed-by. But, no need to resend, I'll fix it up.
 

Ok, I would have preferred an explicit one ;)

 Also, everything above the '---' will be part of your commit log. While
 the Signed-off-by and Reviewed-by should be in there, Cc's really don't
 need to.
 

Ok, it seemed common practice to put it in the commit log:

$ git log | grep Cc: | wc -l
157126

But I'll do as you suggest from now. Actually, I didn't know you could
do like that.

 You can add another '---' to separate commit message and some stuff
 you want to have early in you email with:
 
 Blablabla commit message.
 
 Signed-off-by: ...
 Reviewed-by: ...
 ---
 Changelog:
 - blabla
 
 Cc: cc-me-recipient
 ...
 ---
.../devicetree/bindings/clock/berlin-clock.txt | 29
 ++
1 file changed, 29 insertions(+)
create mode 100644
 Documentation/devicetree/bindings/clock/berlin-clock.txt
 
  diff --git
 a/Documentation/devicetree/bindings/clock/berlin-clock.txt
 b/Documentation/devicetree/bindings/clock/berlin-clock.txt
 ...
 
 Signed-off-by: Alexandre Belloni alexandre.bell...@free-electrons.com
 ---
   .../devicetree/bindings/clock/berlin-clock.txt | 29 
  ++
   1 file changed, 29 insertions(+)
   create mode 100644 Documentation/devicetree/bindings/clock/berlin-clock.txt
 
 diff --git a/Documentation/devicetree/bindings/clock/berlin-clock.txt 
 b/Documentation/devicetree/bindings/clock/berlin-clock.txt
 new file mode 100644
 index ..49b7860bffb8
 --- /dev/null
 +++ b/Documentation/devicetree/bindings/clock/berlin-clock.txt
 @@ -0,0 +1,29 @@
 +Device Tree Clock bindings for Marvell Berlin clocks
 +
 +This binding uses the common clock binding[1].
 +
 +[1] Documentation/devicetree/bindings/clock/clock-bindings.txt
 +
 +Required properties:
 +- compatible: shall be one of the following:
 +marvell,berlin2-pll,
 +marvell,berlin2q-pll:
 +CPU PLL and System PLL
 +- reg: Address and length of the clock register set.
 +- #clock-cells: from common clock binding; shall be set to 0.
 +- clocks: from common clock binding
 +
 +smclk: sysmgr-clock {
 +compatible = fixed-clock;
 +#clock-cells = 0;
 +clock-frequency = 2500;
 +};
 +
 +cpupll: cpupll@ea003c {
 +compatible = marvell,berlin2-pll;
 +clocks = smclk;
 +#clock-cells = 0;
 +reg = 0xea003c 0x8;
 +};
 +
 +
 
 

-- 
Alexandre Belloni, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH v2 1/5] clk: berlin: add support for berlin plls

2014-03-21 Thread Alexandre Belloni
On 21/03/2014 at 22:22:33 +0100, Sebastian Hesselbarth wrote :
 On 03/21/2014 09:08 PM, Alexandre Belloni wrote:
 This drivers allows to provide DT clocks for the cpu and system PLLs found on
 Marvell Berlin SoCs.
 
 Alexandre,
 
 as mentioned on IRC, I now had a closer look on it. Some minor
 remarks below. Sorry, I didn't mention them earlier.
 

To clarify things, I'll just resend patch 1 and you are ready to take
2-5, fixing up the remaining comments as soon as Mike takes it ?


-- 
Alexandre Belloni, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH v3] ARM: at91: Fix link breakage when !CONFIG_PHYLIB

2013-06-04 Thread Alexandre Belloni
On 04/06/2013 15:49, Nicolas Ferre wrote:

 ... simply use this IS_BUILTIN(CONFIG_PHYLIB) here -^
 (and not above as suggested by Arnd).

 Jean-Christophe, Alexandre: do you agree with this conclusion?

 I plan to stack this patch for next at91-fixes batch.


Yeah, I prepared and tested that last week but didn't send it yet. I can
do it now if you want but you could probably just edit my patch. I'd
like to fix the other platforms too but that probably can wait.

I believe we would still have to fix the phy_register_fixup*() works as
it is always called from arch/ and is clearly not fool proofed enough.
Maybe DT could help ?

Arnd, do you have any input ?

-- 
Alexandre Belloni, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCHv2 1/3] net: phy: prevent linking breakage

2013-06-05 Thread Alexandre Belloni
On 04/06/2013 18:09, Florian Fainelli wrote:
 2013/6/4 Arnd Bergmann a...@arndb.de:
 On Tuesday 04 June 2013 16:36:50 Florian Fainelli wrote:
 It seems to me that what David proposes is to have say an
 arch/arm/mach-foo/phy-fixups.c file which is only enabled when
 CONFIG_PHYLIB is set (obj-$(CONFIG_PHYLIB) += phy-fixup.o), such that
 it does not need to have any conditionnals when calling
 phy_register_fixup. This sounds a little unusual, but why not.
 I don't think it would actually help us, because then we still need
 to declare a local function that gets called from the board init
 code. Instead of doing

 if (IS_ENABLED(CONFIG_PHYLIB))
  phy_register_fixup_for_uid(phy_id, foo_phy_fixup);

 we would then do

 if (IS_ENABLED(CONFIG_PHYLIB))
 foo_phy_fixup_register();

 which is not much different at all.
 You would just need to define a stub for your arch_foo_phy_fixup()
 which has a different definition depending on whether CONFIG_PHYLIB is
 defined or not.

 This would be just one function, instead of the whole bunch of stubs
 needed for phylib. Right now its probably 1 vs 3, so it does not make
 that much of a difference but who knows, if we had more phylib stubs
 and forget to update the stubs? (which tends to happen pretty often).

The fact is that for now it is called on 6 different platforms. Of those:
 - two (imx and mxs) are now doing it right *after* discovering the issue
 - two always selecting PHYLIB and can't be compiled without NET
 - two will break at compile time.

I'm really concerned about getting more platforms getting it wrong. I
think it boils down to who wants to take the maintenance burden. I would
believe that doing it in phylib is more future proof. But I'm fine
with whatever the consensus will be.

However, it is becoming urgent for Atmel to get the fix in 3.10 so that
they never get a kernel compilation that breaks.

Regards,

-- 
Alexandre Belloni, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCHv4] ARM: at91: Fix link breakage when !CONFIG_PHYLIB

2013-06-05 Thread Alexandre Belloni
Fixes:
arch/arm/mach-at91/built-in.o: In function `ksz9021rn_phy_fixup':
:(.text+0x1174): undefined reference to `mdiobus_write'
:(.text+0x1188): undefined reference to `mdiobus_write'
:(.text+0x119c): undefined reference to `mdiobus_write'
:(.text+0x11b0): undefined reference to `mdiobus_write'
arch/arm/mach-at91/built-in.o: In function `sama5_dt_device_init':
:(.init.text+0x1e34): undefined reference to `phy_register_fixup_for_uid'

when CONFIG_PHYLIB is not selected.

Signed-off-by: Alexandre Belloni alexandre.bell...@free-electrons.com
---
 arch/arm/mach-at91/Kconfig  | 1 +
 arch/arm/mach-at91/board-dt-sama5.c | 3 ++-
 2 files changed, 3 insertions(+), 1 deletion(-)

diff --git a/arch/arm/mach-at91/Kconfig b/arch/arm/mach-at91/Kconfig
index 0280238..699b71e 100644
--- a/arch/arm/mach-at91/Kconfig
+++ b/arch/arm/mach-at91/Kconfig
@@ -163,6 +163,7 @@ config MACH_SAMA5_DT
bool Atmel SAMA5 Evaluation Kits with device-tree support
depends on SOC_SAMA5
select USE_OF
+   select PHYLIB if NETDEVICES
help
  Select this if you want to experiment device-tree with
  an Atmel Evaluation Kit.
diff --git a/arch/arm/mach-at91/board-dt-sama5.c 
b/arch/arm/mach-at91/board-dt-sama5.c
index 705305e..ad95f6a 100644
--- a/arch/arm/mach-at91/board-dt-sama5.c
+++ b/arch/arm/mach-at91/board-dt-sama5.c
@@ -62,7 +62,8 @@ static int ksz9021rn_phy_fixup(struct phy_device *phy)
 
 static void __init sama5_dt_device_init(void)
 {
-   if (of_machine_is_compatible(atmel,sama5d3xcm))
+   if (of_machine_is_compatible(atmel,sama5d3xcm) 
+   IS_ENABLED(CONFIG_PHYLIB))
phy_register_fixup_for_uid(PHY_ID_KSZ9021, MICREL_PHY_ID_MASK,
ksz9021rn_phy_fixup);
 
-- 
1.8.1.2

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [Arm-netbook] getting allwinner SoC support upstream (was Re: Uploading linux (3.9.4-1))

2013-06-07 Thread Alexandre Belloni
On 07/06/2013 10:06, luke.leighton wrote:
 On Fri, Jun 7, 2013 at 8:48 AM, Vladimir Pantelic vlado...@gmail.com wrote:
 luke.leighton wrote:
   3 days remaining on the clock.

 what catastrophic thing will happen when the time runs out?
  no catastrophe, vladimir: all that happens is that an opportunity is
 lost, and the result of that is that the situation remains as it is,
 with a major soc vendor being divorced from and isolated from the free
 software community, who will continue to have to shoulder the
 frustrating and isolated burden of responsibility of reworking
 over-the-fence kernel patches as best they can with the limited
 resources that they have.

I think the question was: what will be done in 3 days that cannot be
undone ? and you didn't answer that. I don't understand why your are
still stating that Allwinner will never be able to get code in the
mainline after Olof and Maxime told you that they are already working,
at least discussing with them.

-- 
Alexandre Belloni, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCHv2 1/3] iio: Add Nuvoton NAU7802 ADC driver

2013-06-22 Thread Alexandre Belloni
On 22/06/2013 14:02, Lars-Peter Clausen wrote:
 On 06/22/2013 01:55 PM, Jonathan Cameron wrote:
 On 06/20/2013 07:57 PM, Alexandre Belloni wrote:
 The Nuvoton NAU7802 ADC is a 24-bit 2-channels I2C ADC, with adjustable
 gain and sampling rates.

 Sorry, somewhat low on time today so only a quick review.

 1) Missing userspace ABI documentation.  Also, perhaps min_conversions is
a little vague?  Not that I have a better idea!
 I really don't like the name min_conversions either. Isn't this effectively
 a decimation filter?

Yeah, it could be seen like that but it is only relevant and only
happens when switching between channels. I'm open to any ideas.


-- 
Alexandre Belloni, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCHv2 1/3] iio: Add Nuvoton NAU7802 ADC driver

2013-06-22 Thread Alexandre Belloni
On 22/06/2013 15:20, Lars-Peter Clausen wrote:
 On 06/22/2013 03:07 PM, Alexandre Belloni wrote:
 On 22/06/2013 14:02, Lars-Peter Clausen wrote:
 On 06/22/2013 01:55 PM, Jonathan Cameron wrote:
 On 06/20/2013 07:57 PM, Alexandre Belloni wrote:
 The Nuvoton NAU7802 ADC is a 24-bit 2-channels I2C ADC, with adjustable
 gain and sampling rates.

 Sorry, somewhat low on time today so only a quick review.

 1) Missing userspace ABI documentation.  Also, perhaps min_conversions is
a little vague?  Not that I have a better idea!
 I really don't like the name min_conversions either. Isn't this effectively
 a decimation filter?
 Yeah, it could be seen like that but it is only relevant and only
 happens when switching between channels. I'm open to any ideas.

 I see. Is there anything about this in the datasheet on how many conversions
 you usually need? Is this really something you need to change at runtime or
 does moving this to platform data work?



There is actually nothing in the datasheet. The default value (6
conversions) was found experimentally. What I did was saturating the ADC
with the higher value on one channel and the lower value on the other
one and I tried to find when reading both channel sequentially was
resulting in a correct value.

You may not need to change it at runtime. And that value mainly depend
on the precision versus speed balance you want to achieve. If you know
that the values on both channels will not be to far apart, then you may
not need to wait at all.

Would you think that is something I should hide in the DT ? Or maybe I
can drop that knob for now and see if it is needed in the future.

-- 
Alexandre Belloni, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCHv2 1/3] iio: Add Nuvoton NAU7802 ADC driver

2013-06-24 Thread Alexandre Belloni
On 24/06/2013 08:41, Lars-Peter Clausen wrote:
 On 06/20/2013 08:57 PM, Alexandre Belloni wrote:
 The Nuvoton NAU7802 ADC is a 24-bit 2-channels I2C ADC, with adjustable
 gain and sampling rates.

 Signed-off-by: Alexandre Belloni alexandre.bell...@free-electrons.com
 Signed-off-by: Maxime Ripard maxime.rip...@free-electrons.com
 ---
  .../bindings/iio/adc/nuvoton-nau7802.txt   |  17 +
  drivers/iio/adc/Kconfig|   9 +
  drivers/iio/adc/Makefile   |   1 +
  drivers/iio/adc/nau7802.c  | 603 
 +
  4 files changed, 630 insertions(+)
  create mode 100644 
 Documentation/devicetree/bindings/iio/adc/nuvoton-nau7802.txt
  create mode 100644 drivers/iio/adc/nau7802.c

 diff --git a/Documentation/devicetree/bindings/iio/adc/nuvoton-nau7802.txt 
 b/Documentation/devicetree/bindings/iio/adc/nuvoton-nau7802.txt
 new file mode 100644
 index 000..9bc4218
 --- /dev/null
 +++ b/Documentation/devicetree/bindings/iio/adc/nuvoton-nau7802.txt
 @@ -0,0 +1,17 @@
 +* Nuvoton NAU7802 Analog to Digital Converter (ADC)use
 +
 +Required properties:
 +  - compatible: Should be nuvoton,nau7802
 +  - reg: Should contain the ADC I2C address
 +
 +Optional properties:
 +  - nuvoton,vldo: Reference voltage in millivolts (integer)
 +  - interrupts: IRQ line for the ADC. If not used the driver will use
 +polling.
 +
 +Example:
 +adc2: nau7802@2a {
 +compatible = nuvoton,nau7802;
 +reg = 0x2a;
 +nuvoton,vldo = 3000;
 We usually use the regulator framework for specifying the reference voltage.

I followed what Jonathan said in his review of my first patch. Do we
want to use the regulator framework to set the internal reference
voltage of the ADC ? I agree that if you supply an external voltage, it
will be necessary to use the regulator framework. Unfortunately, I can't
test that here.

 +};
 [...]
 diff --git a/drivers/iio/adc/nau7802.c b/drivers/iio/adc/nau7802.c
 new file mode 100644
 index 000..e1b6981
 --- /dev/null
 +++ b/drivers/iio/adc/nau7802.c
 @@ -0,0 +1,603 @@
 [...]
 +static int nau7802_set_gain(struct nau7802_state *st, int gain)
 +{
 +u8 data;
 +int ret;
 +
 +mutex_lock(st-lock);
 +st-conversion_count = 0;
 +
 +data = i2c_smbus_read_byte_data(st-client, NAU7802_REG_CTRL1);
 +if (data  0)
 +goto nau7802_sysfs_set_gain_out;
 ret will be uninitialized if the goto above is taken

Right, bigger issue, data is u8 so it will never be negative. I'm fixing
that !


 +ret = i2c_smbus_write_byte_data(st-client, NAU7802_REG_CTRL1,
 +(data  (~NAU7802_CTRL1_GAINS_BITS)) |
 +gain);
 +
 +nau7802_sysfs_set_gain_out:
 +mutex_unlock(st-lock);
 +
 +return ret ? ret : 0;
 +}
 [...]
 +static int nau7802_read_irq(struct iio_dev *indio_dev,
 +struct iio_chan_spec const *chan,
 +int *val)
 +{
 +struct nau7802_state *st = iio_priv(indio_dev);
 +int ret;
 +
 +INIT_COMPLETION(st-value_ok);
 +enable_irq(st-client-irq);
 Is it really necessary to enable/disable the IRQ or could you keep it
 enabled all the time?

Fact is that the ADC doesn't really care if you are reading data or not
so you will probably endd up in a situation were you will get 320 IRQ
per second but not caring about the result. We have 3 ADCs on the board.
so that amounts to 960 IRQ per second when we are only reading like once
par second !


-- 
Alexandre Belloni, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCHv2 0/2] HX8357 driver improvement

2013-06-24 Thread Alexandre Belloni
Hi,

This is a set of improvements for the hx8357 driver. The first patch removes the
need to defines IM pins in the device tree. So that it is possible to use the
controller with fixed IM pins.

The second patch adds support for the Himax HX8369 controller which is quite
similar.

Tested on CFA-10055 (hx8357) and CFA-10056 (hx8369).

Alexandre Belloni (1):
  fb: backlight: HX8357: Add HX8369 support

Maxime Ripard (1):
  video: hx8357: Make IM pins optional

 drivers/video/backlight/hx8357.c | 256 +--
 1 file changed, 219 insertions(+), 37 deletions(-)

-- 
1.8.1.2

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCHv2 1/2] video: hx8357: Make IM pins optional

2013-06-24 Thread Alexandre Belloni
From: Maxime Ripard maxime.rip...@free-electrons.com

The IM pins of the HX8357 controller are used to define the interface used to
feed pixel stream to the LCD panel.

Most of the time, these pins are directly routed to either the ground or the VCC
to set their values.

Remove the need to assign GPIOs to these pins when we are in such a case.

Signed-off-by: Maxime Ripard maxime.rip...@free-electrons.com
---
 drivers/video/backlight/hx8357.c | 53 +++-
 1 file changed, 31 insertions(+), 22 deletions(-)

diff --git a/drivers/video/backlight/hx8357.c b/drivers/video/backlight/hx8357.c
index a0482b5..69f5672 100644
--- a/drivers/video/backlight/hx8357.c
+++ b/drivers/video/backlight/hx8357.c
@@ -76,6 +76,7 @@ struct hx8357_data {
unsignedreset;
struct spi_device   *spi;
int state;
+   u8  use_im_pins;
 };
 
 static u8 hx8357_seq_power[] = {
@@ -250,9 +251,11 @@ static int hx8357_lcd_init(struct lcd_device *lcdev)
 * Set the interface selection pins to SPI mode, with three
 * wires
 */
-   gpio_set_value_cansleep(lcd-im_pins[0], 1);
-   gpio_set_value_cansleep(lcd-im_pins[1], 0);
-   gpio_set_value_cansleep(lcd-im_pins[2], 1);
+   if (lcd-use_im_pins) {
+   gpio_set_value_cansleep(lcd-im_pins[0], 1);
+   gpio_set_value_cansleep(lcd-im_pins[1], 0);
+   gpio_set_value_cansleep(lcd-im_pins[2], 1);
+   }
 
/* Reset the screen */
gpio_set_value(lcd-reset, 1);
@@ -424,26 +427,32 @@ static int hx8357_probe(struct spi_device *spi)
return -EINVAL;
}
 
-   for (i = 0; i  HX8357_NUM_IM_PINS; i++) {
-   lcd-im_pins[i] = of_get_named_gpio(spi-dev.of_node,
-   im-gpios, i);
-   if (lcd-im_pins[i] == -EPROBE_DEFER) {
-   dev_info(spi-dev, GPIO requested is not here yet, 
deferring the probe\n);
-   return -EPROBE_DEFER;
-   }
-   if (!gpio_is_valid(lcd-im_pins[i])) {
-   dev_err(spi-dev, Missing dt property: im-gpios\n);
-   return -EINVAL;
+   if (of_find_property(spi-dev.of_node, im-gpios, NULL)) {
+   lcd-use_im_pins = 1;
+
+   for (i = 0; i  HX8357_NUM_IM_PINS; i++) {
+   lcd-im_pins[i] = of_get_named_gpio(spi-dev.of_node,
+   im-gpios, i);
+   if (lcd-im_pins[i] == -EPROBE_DEFER) {
+   dev_info(spi-dev, GPIO requested is not here 
yet, deferring the probe\n);
+   return -EPROBE_DEFER;
+   }
+   if (!gpio_is_valid(lcd-im_pins[i])) {
+   dev_err(spi-dev, Missing dt property: 
im-gpios\n);
+   return -EINVAL;
+   }
+
+   ret = devm_gpio_request_one(spi-dev, lcd-im_pins[i],
+   GPIOF_OUT_INIT_LOW,
+   im_pins);
+   if (ret) {
+   dev_err(spi-dev, failed to request gpio %d: 
%d\n,
+   lcd-im_pins[i], ret);
+   return -EINVAL;
+   }
}
-
-   ret = devm_gpio_request_one(spi-dev, lcd-im_pins[i],
-   GPIOF_OUT_INIT_LOW, im_pins);
-   if (ret) {
-   dev_err(spi-dev, failed to request gpio %d: %d\n,
-   lcd-im_pins[i], ret);
-   return -EINVAL;
-   }
-   }
+   } else
+   lcd-use_im_pins = 0;
 
lcdev = lcd_device_register(mxsfb, spi-dev, lcd, hx8357_ops);
if (IS_ERR(lcdev)) {
-- 
1.8.1.2

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCHv2 2/2] fb: backlight: HX8357: Add HX8369 support

2013-06-24 Thread Alexandre Belloni
Add support for the Himax HX8369 controller as it is quite similar to the
hx8357.

Signed-off-by: Alexandre Belloni alexandre.bell...@free-electrons.com
---
 changes since v1:
   - use the data element of of_device_id to select the correct initialization
   function

 drivers/video/backlight/hx8357.c | 203 ---
 1 file changed, 188 insertions(+), 15 deletions(-)

diff --git a/drivers/video/backlight/hx8357.c b/drivers/video/backlight/hx8357.c
index 69f5672..496cb58 100644
--- a/drivers/video/backlight/hx8357.c
+++ b/drivers/video/backlight/hx8357.c
@@ -71,6 +71,18 @@
 #define HX8357_SET_POWER_NORMAL0xd2
 #define HX8357_SET_PANEL_RELATED   0xe9
 
+#define HX8369_SET_DISPLAY_BRIGHTNESS  0x51
+#define HX8369_WRITE_CABC_DISPLAY_VALUE0x53
+#define HX8369_WRITE_CABC_BRIGHT_CTRL  0x55
+#define HX8369_WRITE_CABC_MIN_BRIGHTNESS   0x5e
+#define HX8369_SET_POWER   0xb1
+#define HX8369_SET_DISPLAY_MODE0xb2
+#define HX8369_SET_DISPLAY_WAVEFORM_CYC0xb4
+#define HX8369_SET_VCOM0xb6
+#define HX8369_SET_EXTENSION_COMMAND   0xb9
+#define HX8369_SET_GIP 0xd5
+#define HX8369_SET_GAMMA_CURVE_RELATED 0xe0
+
 struct hx8357_data {
unsignedim_pins[HX8357_NUM_IM_PINS];
unsignedreset;
@@ -144,6 +156,61 @@ static u8 hx8357_seq_display_mode[] = {
HX8357_SET_DISPLAY_MODE_RGB_INTERFACE,
 };
 
+static u8 hx8369_seq_write_CABC_min_brightness[] = {
+   HX8369_WRITE_CABC_MIN_BRIGHTNESS, 0x00,
+};
+
+static u8 hx8369_seq_write_CABC_control[] = {
+   HX8369_WRITE_CABC_DISPLAY_VALUE, 0x24,
+};
+
+static u8 hx8369_seq_set_display_brightness[] = {
+   HX8369_SET_DISPLAY_BRIGHTNESS, 0xFF,
+};
+
+static u8 hx8369_seq_write_CABC_control_setting[] = {
+   HX8369_WRITE_CABC_BRIGHT_CTRL, 0x02,
+};
+
+static u8 hx8369_seq_extension_command[] = {
+   HX8369_SET_EXTENSION_COMMAND, 0xff, 0x83, 0x69,
+};
+
+static u8 hx8369_seq_display_related[] = {
+   HX8369_SET_DISPLAY_MODE, 0x00, 0x2b, 0x03, 0x03, 0x70, 0x00,
+   0xff, 0x00, 0x00, 0x00, 0x00, 0x03, 0x03, 0x00, 0x01,
+};
+
+static u8 hx8369_seq_panel_waveform_cycle[] = {
+   HX8369_SET_DISPLAY_WAVEFORM_CYC, 0x0a, 0x1d, 0x80, 0x06, 0x02,
+};
+
+static u8 hx8369_seq_set_address_mode[] = {
+   HX8357_SET_ADDRESS_MODE, 0x00,
+};
+
+static u8 hx8369_seq_vcom[] = {
+   HX8369_SET_VCOM, 0x3e, 0x3e,
+};
+
+static u8 hx8369_seq_gip[] = {
+   HX8369_SET_GIP, 0x00, 0x01, 0x03, 0x25, 0x01, 0x02, 0x28, 0x70,
+   0x11, 0x13, 0x00, 0x00, 0x40, 0x26, 0x51, 0x37, 0x00, 0x00, 0x71,
+   0x35, 0x60, 0x24, 0x07, 0x0f, 0x04, 0x04,
+};
+
+static u8 hx8369_seq_power[] = {
+   HX8369_SET_POWER, 0x01, 0x00, 0x34, 0x03, 0x00, 0x11, 0x11, 0x32,
+   0x2f, 0x3f, 0x3f, 0x01, 0x3a, 0x01, 0xe6, 0xe6, 0xe6, 0xe6, 0xe6,
+};
+
+static u8 hx8369_seq_gamma_curve_related[] = {
+   HX8369_SET_GAMMA_CURVE_RELATED, 0x00, 0x0d, 0x19, 0x2f, 0x3b, 0x3d,
+   0x2e, 0x4a, 0x08, 0x0e, 0x0f, 0x14, 0x16, 0x14, 0x14, 0x14, 0x1e,
+   0x00, 0x0d, 0x19, 0x2f, 0x3b, 0x3d, 0x2e, 0x4a, 0x08, 0x0e, 0x0f,
+   0x14, 0x16, 0x14, 0x14, 0x14, 0x1e,
+};
+
 static int hx8357_spi_write_then_read(struct lcd_device *lcdev,
u8 *txbuf, u16 txlen,
u8 *rxbuf, u16 rxlen)
@@ -242,6 +309,18 @@ static int hx8357_exit_standby(struct lcd_device *lcdev)
return 0;
 }
 
+static void hx8357_lcd_reset(struct lcd_device *lcdev)
+{
+   struct hx8357_data *lcd = lcd_get_data(lcdev);
+
+   gpio_set_value(lcd-reset, 1);
+   usleep_range(1, 12000);
+   gpio_set_value(lcd-reset, 0);
+   usleep_range(1, 12000);
+   gpio_set_value(lcd-reset, 1);
+   msleep(120);
+}
+
 static int hx8357_lcd_init(struct lcd_device *lcdev)
 {
struct hx8357_data *lcd = lcd_get_data(lcdev);
@@ -257,14 +336,6 @@ static int hx8357_lcd_init(struct lcd_device *lcdev)
gpio_set_value_cansleep(lcd-im_pins[2], 1);
}
 
-   /* Reset the screen */
-   gpio_set_value(lcd-reset, 1);
-   usleep_range(1, 12000);
-   gpio_set_value(lcd-reset, 0);
-   usleep_range(1, 12000);
-   gpio_set_value(lcd-reset, 1);
-   msleep(120);
-
ret = hx8357_spi_write_array(lcdev, hx8357_seq_power,
ARRAY_SIZE(hx8357_seq_power));
if (ret  0)
@@ -359,6 +430,94 @@ static int hx8357_lcd_init(struct lcd_device *lcdev)
return 0;
 }
 
+static int hx8369_lcd_init(struct lcd_device *lcdev)
+{
+   int ret;
+
+   ret = hx8357_spi_write_array(lcdev, hx8369_seq_extension_command,
+   ARRAY_SIZE(hx8369_seq_extension_command));
+   if (ret  0)
+   return ret;
+   usleep_range(1, 12000);
+
+   ret = hx8357_spi_write_array(lcdev

[PATCHv3 3/3] ARM: mxs: cfa10049: Add NAU7802 ADCs to the device tree

2013-06-24 Thread Alexandre Belloni
From: Maxime Ripard maxime.rip...@free-electrons.com

Since these ADCs share the same non-configurable address on the I2C bus,
they have to be put behind a muxer.

Signed-off-by: Alexandre Belloni alexandre.bell...@free-electrons.com
Signed-off-by: Maxime Ripard maxime.rip...@free-electrons.com
---
 arch/arm/boot/dts/imx28-cfa10049.dts | 18 ++
 1 file changed, 18 insertions(+)

diff --git a/arch/arm/boot/dts/imx28-cfa10049.dts 
b/arch/arm/boot/dts/imx28-cfa10049.dts
index d3758c2..efc4213 100644
--- a/arch/arm/boot/dts/imx28-cfa10049.dts
+++ b/arch/arm/boot/dts/imx28-cfa10049.dts
@@ -356,18 +356,36 @@
reg = 0;
#address-cells = 1;
#size-cells = 0;
+
+   adc0: nau7802@2a {
+   compatible = nuvoton,nau7802;
+   reg = 0x2a;
+   nuvoton,vldo = 3000;
+   };
};
 
i2c@1 {
reg = 1;
#address-cells = 1;
#size-cells = 0;
+
+   adc1: nau7802@2a {
+   compatible = nuvoton,nau7802;
+   reg = 0x2a;
+   nuvoton,vldo = 3000;
+   };
};
 
i2c@2 {
reg = 2;
#address-cells = 1;
#size-cells = 0;
+
+   adc2: nau7802@2a {
+   compatible = nuvoton,nau7802;
+   reg = 0x2a;
+   nuvoton,vldo = 3000;
+   };
};
 
i2c@3 {
-- 
1.8.1.2

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCHv3 1/3] iio: Add Nuvoton NAU7802 ADC driver

2013-06-24 Thread Alexandre Belloni
The Nuvoton NAU7802 ADC is a 24-bit 2-channels I2C ADC, with adjustable
gain and sampling rates.

Signed-off-by: Alexandre Belloni alexandre.bell...@free-electrons.com
Signed-off-by: Maxime Ripard maxime.rip...@free-electrons.com
---
 .../bindings/iio/adc/nuvoton-nau7802.txt   |  18 +
 drivers/iio/adc/Kconfig|   9 +
 drivers/iio/adc/Makefile   |   1 +
 drivers/iio/adc/nau7802.c  | 576 +
 4 files changed, 604 insertions(+)
 create mode 100644 
Documentation/devicetree/bindings/iio/adc/nuvoton-nau7802.txt
 create mode 100644 drivers/iio/adc/nau7802.c

diff --git a/Documentation/devicetree/bindings/iio/adc/nuvoton-nau7802.txt 
b/Documentation/devicetree/bindings/iio/adc/nuvoton-nau7802.txt
new file mode 100644
index 000..e9582e6
--- /dev/null
+++ b/Documentation/devicetree/bindings/iio/adc/nuvoton-nau7802.txt
@@ -0,0 +1,18 @@
+* Nuvoton NAU7802 Analog to Digital Converter (ADC)
+
+Required properties:
+  - compatible: Should be nuvoton,nau7802
+  - reg: Should contain the ADC I2C address
+
+Optional properties:
+  - nuvoton,vldo: Internal reference voltage in millivolts to be
+configured valid values are between 2400 mV and 4500 mV.
+  - interrupts: IRQ line for the ADC. If not used the driver will use
+polling.
+
+Example:
+adc2: nau7802@2a {
+   compatible = nuvoton,nau7802;
+   reg = 0x2a;
+   nuvoton,vldo = 3000;
+};
diff --git a/drivers/iio/adc/Kconfig b/drivers/iio/adc/Kconfig
index ab0767e6..d7f9ed8 100644
--- a/drivers/iio/adc/Kconfig
+++ b/drivers/iio/adc/Kconfig
@@ -133,6 +133,15 @@ config MAX1363
  max11646, max11647) Provides direct access via sysfs and buffered
  data via the iio dev interface.
 
+config NAU7802
+   tristate Nuvoton NAU7802 ADC driver
+   depends on I2C
+   help
+ Say yes here to build support for Nuvoton NAU7802 ADC.
+
+ To compile this driver as a module, choose M here: the
+ module will be called nau7802.
+
 config TI_ADC081C
tristate Texas Instruments ADC081C021/027
depends on I2C
diff --git a/drivers/iio/adc/Makefile b/drivers/iio/adc/Makefile
index 0a825be..d426081 100644
--- a/drivers/iio/adc/Makefile
+++ b/drivers/iio/adc/Makefile
@@ -14,6 +14,7 @@ obj-$(CONFIG_AT91_ADC) += at91_adc.o
 obj-$(CONFIG_EXYNOS_ADC) += exynos_adc.o
 obj-$(CONFIG_LP8788_ADC) += lp8788_adc.o
 obj-$(CONFIG_MAX1363) += max1363.o
+obj-$(CONFIG_NAU7802) += nau7802.o
 obj-$(CONFIG_TI_ADC081C) += ti-adc081c.o
 obj-$(CONFIG_TI_AM335X_ADC) += ti_am335x_adc.o
 obj-$(CONFIG_VIPERBOARD_ADC) += viperboard_adc.o
diff --git a/drivers/iio/adc/nau7802.c b/drivers/iio/adc/nau7802.c
new file mode 100644
index 000..c5f99a2
--- /dev/null
+++ b/drivers/iio/adc/nau7802.c
@@ -0,0 +1,576 @@
+/*
+ * Driver for the Nuvoton NAU7802 ADC
+ *
+ * Copyright 2013 Free Electrons
+ *
+ * Licensed under the GPLv2 or later.
+ */
+
+#include linux/delay.h
+#include linux/i2c.h
+#include linux/interrupt.h
+#include linux/module.h
+#include linux/wait.h
+#include linux/log2.h
+
+#include linux/iio/iio.h
+#include linux/iio/sysfs.h
+
+#define NAU7802_REG_PUCTRL 0x00
+#define NAU7802_PUCTRL_RR(x)   (x  0)
+#define NAU7802_PUCTRL_RR_BIT  NAU7802_PUCTRL_RR(1)
+#define NAU7802_PUCTRL_PUD(x)  (x  1)
+#define NAU7802_PUCTRL_PUD_BIT NAU7802_PUCTRL_PUD(1)
+#define NAU7802_PUCTRL_PUA(x)  (x  2)
+#define NAU7802_PUCTRL_PUA_BIT NAU7802_PUCTRL_PUA(1)
+#define NAU7802_PUCTRL_PUR(x)  (x  3)
+#define NAU7802_PUCTRL_PUR_BIT NAU7802_PUCTRL_PUR(1)
+#define NAU7802_PUCTRL_CS(x)   (x  4)
+#define NAU7802_PUCTRL_CS_BIT  NAU7802_PUCTRL_CS(1)
+#define NAU7802_PUCTRL_CR(x)   (x  5)
+#define NAU7802_PUCTRL_CR_BIT  NAU7802_PUCTRL_CR(1)
+#define NAU7802_PUCTRL_AVDDS(x)(x  7)
+#define NAU7802_PUCTRL_AVDDS_BIT   NAU7802_PUCTRL_AVDDS(1)
+#define NAU7802_REG_CTRL1  0x01
+#define NAU7802_CTRL1_VLDO(x)  (x  3)
+#define NAU7802_CTRL1_GAINS(x) (x)
+#define NAU7802_CTRL1_GAINS_BITS   0x07
+#define NAU7802_REG_CTRL2  0x02
+#define NAU7802_CTRL2_CHS(x)   (x  7)
+#define NAU7802_CTRL2_CRS(x)   (x  4)
+#define NAU7802_SAMP_FREQ_320  0x07
+#define NAU7802_CTRL2_CHS_BIT  NAU7802_CTRL2_CHS(1)
+#define NAU7802_REG_ADC_B2 0x12
+#define NAU7802_REG_ADC_B1 0x13
+#define NAU7802_REG_ADC_B0 0x14
+#define NAU7802_REG_ADC_CTRL   0x15
+
+#define NAU7802_MIN_CONVERSIONS 6
+
+struct nau7802_state {
+   struct i2c_client   *client;
+   s32 last_value;
+   struct mutexlock;
+   struct mutexdata_lock;
+   u32 vref_mv;
+   u32 conversion_count;
+   u32 min_conversions;
+   u8  sample_rate;
+   u32 scale_avail[8];
+   struct

[PATCHv3 0/3] Add support for the Nuvoton NAU7802 ADC to the cfa10049

2013-06-24 Thread Alexandre Belloni
Hi,

This is v3 of the patchset that adds support for the 3 Nuvoton NAU7802 ADCs
present on the CFA-10049 board from Crystalfontz. The first patch adds the
driver, the next ones are adding them in the DT after switching the second i2c
bus to bitbanging following a lot of timeout issues we have on that bus.

Changes in v3:
 - removed the min_conversion knob in sysfs, it is now hardcoded to 6
 - added error checking in probe
 - corrected error checking
 - corrected possibly uninitialized vldo
 - used ARRAY_SIZE(nau7802_chan_array) instead of 2
 - added that vldo refers to the internal voltage regulator

Changes in v2:
 - channels are now statically allocated
 - no wrappers around i2c functions
 - sampling_freq is a shared attribute
 - setting gain is done through scale
 - cosmetics changes (s/idev/indio_dev/, blank lines before returns)
 - use of sign_extend32 to extend the sign
 - reading scale now returns IIO_VAL_FRACTIONAL_LOG2
 - no dt lookup for interrupts, this is done in of_i2c.c but that was mask due
 to a bug.

what I didn't address is setting the external reference voltage through a fixed
regulator and I kept the vldo attribute to set the internal voltage reference in
the DT as Jonathan seemed to be ok with that. If anybody is using a nau7802 with
an external reference, it will still be time to add the fixed regulator. It
shouldn't be difficult but I don't have any hardware to test.

Regards,

Alexandre Belloni (1):
  iio: Add Nuvoton NAU7802 ADC driver

Maxime Ripard (2):
  ARM: mxs: cfa10049: Switch bus i2c1 to bitbanging
  ARM: mxs: cfa10049: Add NAU7802 ADCs to the device tree

 .../bindings/iio/adc/nuvoton-nau7802.txt   |  18 +
 arch/arm/boot/dts/imx28-cfa10049.dts   | 126 +++--
 drivers/iio/adc/Kconfig|   9 +
 drivers/iio/adc/Makefile   |   1 +
 drivers/iio/adc/nau7802.c  | 576 +
 5 files changed, 687 insertions(+), 43 deletions(-)
 create mode 100644 
Documentation/devicetree/bindings/iio/adc/nuvoton-nau7802.txt
 create mode 100644 drivers/iio/adc/nau7802.c

-- 
1.8.1.2

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCHv3 2/3] ARM: mxs: cfa10049: Switch bus i2c1 to bitbanging

2013-06-24 Thread Alexandre Belloni
From: Maxime Ripard maxime.rip...@free-electrons.com

The ADCs connected to this bus have been experiencing some timeout
issues when using the iMX28 i2c controller. Switching back to bitbanging
solves this.

Signed-off-by: Maxime Ripard maxime.rip...@free-electrons.com
Signed-off-by: Alexandre Belloni alexandre.bell...@free-electrons.com
---
 arch/arm/boot/dts/imx28-cfa10049.dts | 108 +--
 1 file changed, 65 insertions(+), 43 deletions(-)

diff --git a/arch/arm/boot/dts/imx28-cfa10049.dts 
b/arch/arm/boot/dts/imx28-cfa10049.dts
index 05ae549..d3758c2 100644
--- a/arch/arm/boot/dts/imx28-cfa10049.dts
+++ b/arch/arm/boot/dts/imx28-cfa10049.dts
@@ -139,6 +139,17 @@
fsl,pull-up = 0; /* 0 will enable the 
keeper */
};
 
+   i2c1_pins_cfa10049: i2c1@0 {
+   reg = 0;
+   fsl,pinmux-ids = 
+   0x3103 /* MX28_PAD_PWM0__GPIO */
+   0x3113 /* 
MX28_PAD_PWM1__I2C1_SDA */
+   ;
+   fsl,drive-strength = 1;
+   fsl,voltage = 1;
+   fsl,pull-up = 1;
+   };
+
fiq_pins_cfa10049: fiq@0 {
reg = 0;
fsl,pinmux-ids = 
@@ -199,49 +210,6 @@
status = okay;
};
 
-   i2c1: i2c@8005a000 {
-   pinctrl-names = default;
-   pinctrl-0 = i2c1_pins_a;
-   status = okay;
-   };
-
-   i2cmux {
-   compatible = i2c-mux-gpio;
-   #address-cells = 1;
-   #size-cells = 0;
-   mux-gpios = gpio1 22 0 gpio1 23 0;
-   i2c-parent = i2c1;
-
-   i2c@0 {
-   reg = 0;
-   };
-
-   i2c@1 {
-   reg = 1;
-   };
-
-   i2c@2 {
-   reg = 2;
-   };
-
-   i2c@3 {
-   reg = 3;
-   #address-cells = 1;
-   #size-cells = 0;
-
-   pca9555: pca9555@20 {
-   compatible = nxp,pca9555;
-   interrupt-parent = gpio2;
-   interrupts = 19 0x2;
-   gpio-controller;
-   #gpio-cells = 2;
-   interrupt-controller;
-   #interrupt-cells = 2;
-   reg = 0x20;
-   };
-   };
-   };
-
usbphy1: usbphy@8007e000 {
status = okay;
};
@@ -366,6 +334,60 @@
rotary-encoder,relative-axis;
};
 
+   i2c1gpio: i2c@0 {
+   compatible = i2c-gpio;
+   pinctrl-0 = i2c1_pins_cfa10049;
+   pinctrl-names = default;
+   gpios = 
+   gpio3 17 0 /* sda */
+   gpio3 16 0 /* scl */
+;
+   i2c-gpio,delay-us = 2;/* ~100 kHz */
+   };
+
+   i2cmux {
+   compatible = i2c-mux-gpio;
+   #address-cells = 1;
+   #size-cells = 0;
+   mux-gpios = gpio1 22 0 gpio1 23 0;
+   i2c-parent = i2c1gpio;
+
+   i2c@0 {
+   reg = 0;
+   #address-cells = 1;
+   #size-cells = 0;
+   };
+
+   i2c@1 {
+   reg = 1;
+   #address-cells = 1;
+   #size-cells = 0;
+   };
+
+   i2c@2 {
+   reg = 2;
+   #address-cells = 1;
+   #size-cells = 0;
+   };
+
+   i2c@3 {
+   reg = 3;
+   #address-cells = 1;
+   #size-cells = 0;
+
+   pca9555

Re: [PATCHv2 1/3] iio: Add Nuvoton NAU7802 ADC driver

2013-06-24 Thread Alexandre Belloni
On 24/06/2013 18:41, Lars-Peter Clausen wrote:
 Ah, ok, makes sense.


I just sent v3, thanks for your reviews !

-- 
Alexandre Belloni, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 2/4] arm: mxs: add lradc to cfa10036

2013-06-26 Thread Alexandre Belloni
The lradc is actually available on the Crystalfontz cfa-10036.

Signed-off-by: Alexandre Belloni alexandre.bell...@free-electrons.com
---
 arch/arm/boot/dts/imx28-cfa10036.dts | 4 
 arch/arm/boot/dts/imx28-cfa10049.dts | 1 -
 arch/arm/boot/dts/imx28-cfa10055.dts | 1 -
 3 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/arch/arm/boot/dts/imx28-cfa10036.dts 
b/arch/arm/boot/dts/imx28-cfa10036.dts
index 5e5213f..802e0e9 100644
--- a/arch/arm/boot/dts/imx28-cfa10036.dts
+++ b/arch/arm/boot/dts/imx28-cfa10036.dts
@@ -94,6 +94,10 @@
usbphy0: usbphy@8007c000 {
status = okay;
};
+
+   lradc@8005 {
+   status = okay;
+   };
};
};
 
diff --git a/arch/arm/boot/dts/imx28-cfa10049.dts 
b/arch/arm/boot/dts/imx28-cfa10049.dts
index c26676b..4d3c0a6 100644
--- a/arch/arm/boot/dts/imx28-cfa10049.dts
+++ b/arch/arm/boot/dts/imx28-cfa10049.dts
@@ -215,7 +215,6 @@
};
 
lradc@8005 {
-   status = okay;
fsl,lradc-touchscreen-wires = 4;
};
};
diff --git a/arch/arm/boot/dts/imx28-cfa10055.dts 
b/arch/arm/boot/dts/imx28-cfa10055.dts
index 1581112..e0de1aa 100644
--- a/arch/arm/boot/dts/imx28-cfa10055.dts
+++ b/arch/arm/boot/dts/imx28-cfa10055.dts
@@ -136,7 +136,6 @@
apbx@8004 {
lradc@8005 {
fsl,lradc-touchscreen-wires = 4;
-   status = okay;
};
 
pwm: pwm@80064000 {
-- 
1.8.1.2

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 1/4] arm: mxs: Add #io-channel-cells property to lradc

2013-06-26 Thread Alexandre Belloni
Adding #io-channel-cells property to lradc allows us to use the lradc as an iio
provider.

Signed-off-by: Alexandre Belloni alexandre.bell...@free-electrons.com
---
 arch/arm/boot/dts/imx28.dtsi | 1 +
 1 file changed, 1 insertion(+)

diff --git a/arch/arm/boot/dts/imx28.dtsi b/arch/arm/boot/dts/imx28.dtsi
index 600f7cb..9a7feeb 100644
--- a/arch/arm/boot/dts/imx28.dtsi
+++ b/arch/arm/boot/dts/imx28.dtsi
@@ -829,6 +829,7 @@
interrupts = 10 14 15 16 17 18 19
20 21 22 23 24 25;
status = disabled;
+   #io-channel-cells = 1;
};
 
spdif@80054000 {
-- 
1.8.1.2

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 0/4] Add an hwmon driver for the mxs soc internal sensor

2013-06-26 Thread Alexandre Belloni
This patchset is ading a simple driver for the i.mx28 internal die temperature
sensor.

The first two patches are preparation patches an can be applied now.

The first patch is adding the #io-channel-cells to the lrdac on i.mx28 so that
it becomes an inkernel iio provider.

The second patch defines the lradc as present on the cfa-10036 and thus removes
it from i.mx28-cfa10049.dts and imx28-cfa10055.dts as they both include
imx28-cfa10036.dts

The third patch adds the driver itself.

And the final patch adds the driver bindings to the cfa-10036.

Alexandre Belloni (4):
  arm: mxs: Add #io-channel-cells property to lradc
  arm: mxs: add lradc to cfa10036
  hwmon: Add a simple driver to read the MXS SoC temperature
  arm: mxs: Add mxs internal temp sensor to cfa-10036

 .../devicetree/bindings/hwmon/mxs-cputemp.txt  |  18 +++
 Documentation/hwmon/mxs-cputemp|  29 +
 arch/arm/boot/dts/imx28-cfa10036.dts   |  10 ++
 arch/arm/boot/dts/imx28-cfa10049.dts   |   1 -
 arch/arm/boot/dts/imx28-cfa10055.dts   |   1 -
 arch/arm/boot/dts/imx28.dtsi   |   1 +
 drivers/hwmon/Kconfig  |  10 ++
 drivers/hwmon/Makefile |   1 +
 drivers/hwmon/mxs-cputemp.c| 132 +
 9 files changed, 201 insertions(+), 2 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/hwmon/mxs-cputemp.txt
 create mode 100644 Documentation/hwmon/mxs-cputemp
 create mode 100644 drivers/hwmon/mxs-cputemp.c

-- 
1.8.1.2

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 3/4] hwmon: Add a simple driver to read the MXS SoC temperature

2013-06-26 Thread Alexandre Belloni
The low resolution ADC of the mxs is able to read an internal temperature
sensor, expose that using hwmon.

Signed-off-by: Alexandre Belloni alexandre.bell...@free-electrons.com
---
 .../devicetree/bindings/hwmon/mxs-cputemp.txt  |  18 +++
 Documentation/hwmon/mxs-cputemp|  29 +
 drivers/hwmon/Kconfig  |  10 ++
 drivers/hwmon/Makefile |   1 +
 drivers/hwmon/mxs-cputemp.c| 132 +
 5 files changed, 190 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/hwmon/mxs-cputemp.txt
 create mode 100644 Documentation/hwmon/mxs-cputemp
 create mode 100644 drivers/hwmon/mxs-cputemp.c

diff --git a/Documentation/devicetree/bindings/hwmon/mxs-cputemp.txt 
b/Documentation/devicetree/bindings/hwmon/mxs-cputemp.txt
new file mode 100644
index 000..7d3ae47
--- /dev/null
+++ b/Documentation/devicetree/bindings/hwmon/mxs-cputemp.txt
@@ -0,0 +1,18 @@
+mxs cputemp hwmon sensors
+-
+
+See: Documentation/hwmon/mxs-cputemp
+
+Required properties:
+- compatible: should be fsl,mxs-internal-temp
+- io-channels: should list the two adc channels needed to calculate the
+  temperature
+- io-channel-names: should map the previously listed adc channels to the min
+   and max value
+
+Example:
+   temp {
+   compatible = fsl,mxs-internal-temp;
+   io-channels = lradc 8, lradc 9;
+   io-channel-names = min, max;
+   };
diff --git a/Documentation/hwmon/mxs-cputemp b/Documentation/hwmon/mxs-cputemp
new file mode 100644
index 000..6c6201f
--- /dev/null
+++ b/Documentation/hwmon/mxs-cputemp
@@ -0,0 +1,29 @@
+Kernel driver mxs-cputemp
+=
+
+Supported chips:
+  * Freescale i.mx28
+Datasheet: i.MX28 Applications Processor Reference Manual, Rev. 1, 2010
+  http://cache.freescale.com/files/dsp/doc/ref_manual/MCIMX28RM.pdf
+
+Author: Alexandre Belloni
+
+Description
+---
+This driver permits reading the internal die temperature sensor embedded inside
+Freescale i.mx28 SoCs. This sensor is read through two channels of the on chip
+Low-Resolution ADC. After calculation, the three-sigma error of the temperature
+sensor should be within ± 1.5% in degrees Kelvin. Additionally, the temperature
+sampling has a three-sigma sample-to-sample variation of 2 degrees Kelvin. If
+desired, this error can be removed by oversampling and averaging the 
temperature
+result.
+
+The formula is:
+   (Channel9 – Channel8) * Gain_correction/4
+
+As recommended by the datasheet, Gain_correction is equal to 1.012.
+
+sysfs entries
+-
+temp1_inputMeasured and corrected temperature in millidegrees Celsius
+
diff --git a/drivers/hwmon/Kconfig b/drivers/hwmon/Kconfig
index 0428e8a..2daf794 100644
--- a/drivers/hwmon/Kconfig
+++ b/drivers/hwmon/Kconfig
@@ -929,6 +929,16 @@ config SENSORS_MCP3021
  This driver can also be built as a module.  If so, the module
  will be called mcp3021.
 
+config SENSORS_MXS_CPU
+   tristate MXS internal CPU temperature sensor
+   depends on MXS_LRADC
+   help
+ If you say yes here you get support for the i.mx28 internal
+ temperature sensor.
+
+ This driver can also be built as a module.  If so, the module
+ will be called mxs-cputemp
+
 config SENSORS_NCT6775
tristate Nuvoton NCT6775F and compatibles
depends on !PPC
diff --git a/drivers/hwmon/Makefile b/drivers/hwmon/Makefile
index d17d3e6..366c92d 100644
--- a/drivers/hwmon/Makefile
+++ b/drivers/hwmon/Makefile
@@ -108,6 +108,7 @@ obj-$(CONFIG_SENSORS_MAX6650)   += max6650.o
 obj-$(CONFIG_SENSORS_MAX6697)  += max6697.o
 obj-$(CONFIG_SENSORS_MC13783_ADC)+= mc13783-adc.o
 obj-$(CONFIG_SENSORS_MCP3021)  += mcp3021.o
+obj-$(CONFIG_SENSORS_MXS_CPU)  += mxs-cputemp.o
 obj-$(CONFIG_SENSORS_NCT6775)  += nct6775.o
 obj-$(CONFIG_SENSORS_NTC_THERMISTOR)   += ntc_thermistor.o
 obj-$(CONFIG_SENSORS_PC87360)  += pc87360.o
diff --git a/drivers/hwmon/mxs-cputemp.c b/drivers/hwmon/mxs-cputemp.c
new file mode 100644
index 000..a312fb5
--- /dev/null
+++ b/drivers/hwmon/mxs-cputemp.c
@@ -0,0 +1,132 @@
+/*
+ * Driver for the mxs internal temperature sensor
+ *
+ * Copyright 2013 Free Electrons
+ *
+ * Licensed under the GPLv2 or later.
+ */
+
+#define DRVNAME mxs-hwmon
+
+#include linux/device.h
+#include linux/err.h
+#include linux/hwmon.h
+#include linux/hwmon-sysfs.h
+#include linux/module.h
+#include linux/of.h
+#include linux/of_device.h
+#include linux/platform_device.h
+#include linux/iio/consumer.h
+
+#define GAIN_CORRECTION 1012
+
+/* The value we calculate from the ADCs is in Kelvins, don't forget to convert
+ * it to Celsius */
+#define VALUES_TO_MILLIC(min, max) ((max - min) * GAIN_CORRECTION / 4 - 272150)
+
+struct mxs_hwmon_data {
+   struct device *hwmon_dev;
+   struct iio_channel *chan_min

[PATCH 4/4] arm: mxs: Add mxs internal temp sensor to cfa-10036

2013-06-26 Thread Alexandre Belloni
Signed-off-by: Alexandre Belloni alexandre.bell...@free-electrons.com
---
 arch/arm/boot/dts/imx28-cfa10036.dts | 8 +++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/arch/arm/boot/dts/imx28-cfa10036.dts 
b/arch/arm/boot/dts/imx28-cfa10036.dts
index 802e0e9..5afb945 100644
--- a/arch/arm/boot/dts/imx28-cfa10036.dts
+++ b/arch/arm/boot/dts/imx28-cfa10036.dts
@@ -95,7 +95,7 @@
status = okay;
};
 
-   lradc@8005 {
+   lradc: lradc@8005 {
status = okay;
};
};
@@ -121,4 +121,10 @@
default-state = on;
};
};
+
+   temp {
+   compatible = fsl,mxs-internal-temp;
+   io-channels = lradc 8, lradc 9;
+   io-channel-names = min, max;
+   };
 };
-- 
1.8.1.2

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 2/3] ARM: mxs: dt: Add Crystalfontz CFA-10056 device tree

2013-06-26 Thread Alexandre Belloni
From: Brian Lilly br...@crystalfontz.com

The CFA-10056 is a breakout board for the CFA-10036, and is
basically a CFA-10037, with ai 4.3 screen.

Signed-off-by: Brian Lilly br...@crystalfontz.com
Signed-off-by: Alexandre Belloni alexandre.bell...@free-electrons.com
---
 arch/arm/boot/dts/Makefile   |   1 +
 arch/arm/boot/dts/imx28-cfa10056.dts | 200 +++
 2 files changed, 201 insertions(+)
 create mode 100644 arch/arm/boot/dts/imx28-cfa10056.dts

diff --git a/arch/arm/boot/dts/Makefile b/arch/arm/boot/dts/Makefile
index 225d939..d494f37 100644
--- a/arch/arm/boot/dts/Makefile
+++ b/arch/arm/boot/dts/Makefile
@@ -131,6 +131,7 @@ dtb-$(CONFIG_ARCH_MXS) += imx23-evk.dtb \
imx28-cfa10037.dtb \
imx28-cfa10049.dtb \
imx28-cfa10055.dtb \
+   imx28-cfa10056.dtb \
imx28-cfa10057.dtb \
imx28-evk.dtb \
imx28-m28evk.dtb \
diff --git a/arch/arm/boot/dts/imx28-cfa10056.dts 
b/arch/arm/boot/dts/imx28-cfa10056.dts
new file mode 100644
index 000..47b5016
--- /dev/null
+++ b/arch/arm/boot/dts/imx28-cfa10056.dts
@@ -0,0 +1,200 @@
+/*
+ * Copyright 2012 Free Electrons
+ *
+ * The code contained herein is licensed under the GNU General Public
+ * License. You may obtain a copy of the GNU General Public License
+ * Version 2 or later at the following locations:
+ *
+ * http://www.opensource.org/licenses/gpl-license.html
+ * http://www.gnu.org/copyleft/gpl.html
+ */
+
+/*
+ * The CFA-10056 is an expansion board for the CFA-10036 module, thus we
+ * need to include the CFA-10036 DTS.
+ */
+/include/ imx28-cfa10036.dts
+
+/ {
+   model = Crystalfontz CFA-10056 Board;
+   compatible = crystalfontz,cfa10056, crystalfontz,cfa10036, 
fsl,imx28;
+
+   apb@8000 {
+   apbh@8000 {
+   pinctrl@80018000 {
+   pinctrl-names = default, default;
+   pinctrl-1 = hog_pins_cfa10056
+   hog_pins_cfa10056_pullup;
+
+   hog_pins_cfa10056: hog-10056@0 {
+   reg = 0;
+   fsl,pinmux-ids = 
+   0x0073 /* 
MX28_PAD_GPMI_D7__GPIO_0_7 */
+   0x2153 /* 
MX28_PAD_SSP2_D5__GPIO_2_21 */
+   0x3053 /* 
MX28_PAD_AUART1_TX__GPIO_3_5 */
+   ;
+   fsl,drive-strength = 0;
+   fsl,voltage = 1;
+   fsl,pull-up = 0;
+   };
+
+   hog_pins_cfa10056_pullup: hog-10056-pullup@0 {
+   reg = 0;
+   fsl,pinmux-ids = 
+   0x2133 /* 
MX28_PAD_SSP2_D3__GPIO_2_19 */
+   0x3183 /* 
MX28_PAD_I2C0_SCL__GPIO_3_24 */
+   0x3193 /* 
MX28_PAD_I2C0_SDA__GPIO_3_25 */
+   0x31a3 /* 
MX28_PAD_SAIF_SDATA0__GPIO_3_26 */
+   0x31e3 /* 
MX28_PAD_LCD_RESET__GPIO_3_30 */
+   ;
+   fsl,drive-strength = 0;
+   fsl,voltage = 1;
+   fsl,pull-up = 1;
+   };
+
+   spi2_pins_cfa10056: spi2-cfa10056@0 {
+   reg = 0;
+   fsl,pinmux-ids = 
+   0x2103 /* 
MX28_PAD_SSP2_SCK__GPIO_2_16 */
+   0x2113 /* 
MX28_PAD_SSP2_CMD__GPIO_2_17 */
+   0x2123 /* 
MX28_PAD_SSP2_D0__GPIO_2_18 */
+   ;
+   fsl,drive-strength = 1;
+   fsl,voltage = 1;
+   fsl,pull-up = 1;
+   };
+
+   spi3_pins_cfa10056: spi3-cfa10056@0 {
+   reg = 0;
+   fsl,pinmux-ids = 
+   0x0183 /* 
MX28_PAD_GPMI_RDN__GPIO_0_24 */
+   0x01c3 /* 
MX28_PAD_GPMI_RESETN__GPIO_0_28 */
+   0x0113 /* 
MX28_PAD_GPMI_CE1N__GPIO_0_17 */
+   0x01a3 /* 
MX28_PAD_GPMI_ALE__GPIO_0_26 */
+   0x01b3 /* 
MX28_PAD_GPMI_CLE__GPIO_0_27

[PATCH 3/3] ARM: mxs: dt: Add Crystalfontz CFA-10058 device tree

2013-06-26 Thread Alexandre Belloni
From: Brian Lilly br...@crystalfontz.com

The CFA-10057 is a breakout board for the CFA-10036 that has Ethernet, USB and a
5 LCD screen on it.

Signed-off-by: Brian Lilly br...@crystalfontz.com
Signed-off-by: Alexandre Belloni alexandre.bell...@free-electrons.com
---
 arch/arm/boot/dts/Makefile   |   1 +
 arch/arm/boot/dts/imx28-cfa10058.dts | 183 +++
 2 files changed, 184 insertions(+)
 create mode 100644 arch/arm/boot/dts/imx28-cfa10058.dts

diff --git a/arch/arm/boot/dts/Makefile b/arch/arm/boot/dts/Makefile
index d494f37..ddd6f32 100644
--- a/arch/arm/boot/dts/Makefile
+++ b/arch/arm/boot/dts/Makefile
@@ -133,6 +133,7 @@ dtb-$(CONFIG_ARCH_MXS) += imx23-evk.dtb \
imx28-cfa10055.dtb \
imx28-cfa10056.dtb \
imx28-cfa10057.dtb \
+   imx28-cfa10058.dtb \
imx28-evk.dtb \
imx28-m28evk.dtb \
imx28-sps1.dtb \
diff --git a/arch/arm/boot/dts/imx28-cfa10058.dts 
b/arch/arm/boot/dts/imx28-cfa10058.dts
new file mode 100644
index 000..438e042
--- /dev/null
+++ b/arch/arm/boot/dts/imx28-cfa10058.dts
@@ -0,0 +1,183 @@
+/*
+ * Copyright 2013 Crystalfontz America, Inc.
+ * Copyright 2012 Free Electrons
+ *
+ * The code contained herein is licensed under the GNU General Public
+ * License. You may obtain a copy of the GNU General Public License
+ * Version 2 or later at the following locations:
+ *
+ * http://www.opensource.org/licenses/gpl-license.html
+ * http://www.gnu.org/copyleft/gpl.html
+ */
+
+/*
+ * The CFA-100587 is an expansion board for the CFA-10036 module, thus we
+ * need to include the CFA-10036 DTS.
+ */
+/include/ imx28-cfa10036.dts
+
+/ {
+   model = Crystalfontz CFA-10058 Board;
+   compatible = crystalfontz,cfa10058, crystalfontz,cfa10036, 
fsl,imx28;
+
+   apb@8000 {
+   apbh@8000 {
+   pinctrl@80018000 {
+   pinctrl-names = default, default;
+   pinctrl-1 = hog_pins_cfa10058
+   hog_pins_cfa10058_pullup;
+
+   hog_pins_cfa10058: hog-10058@0 {
+   reg = 0;
+   fsl,pinmux-ids = 
+   0x0073 /* 
MX28_PAD_GPMI_D7__GPIO_0_7 */
+   0x3053 /* 
MX28_PAD_AUART1_TX__GPIO_3_5 */
+   ;
+   fsl,drive-strength = 0;
+   fsl,voltage = 1;
+   fsl,pull-up = 0;
+   };
+
+   hog_pins_cfa10058_pullup: hog-10058-pullup@0 {
+   reg = 0;
+   fsl,pinmux-ids = 
+   0x2133 /* 
MX28_PAD_SSP2_D3__GPIO_2_19 */
+   0x3183 /* 
MX28_PAD_I2C0_SCL__GPIO_3_24 */
+   0x3193 /* 
MX28_PAD_I2C0_SDA__GPIO_3_25 */
+   0x31a3 /* 
MX28_PAD_SAIF_SDATA0__GPIO_3_26 */
+   0x31e3 /* 
MX28_PAD_LCD_RESET__GPIO_3_30 */
+   ;
+   fsl,drive-strength = 0;
+   fsl,voltage = 1;
+   fsl,pull-up = 1;
+   };
+
+   spi3_pins_cfa10058: spi3-cfa10058@0 {
+   reg = 0;
+   fsl,pinmux-ids = 
+   0x0183 /* 
MX28_PAD_GPMI_RDN__GPIO_0_24 */
+   0x01c3 /* 
MX28_PAD_GPMI_RESETN__GPIO_0_28 */
+   0x0113 /* 
MX28_PAD_GPMI_CE1N__GPIO_0_17 */
+   0x01a3 /* 
MX28_PAD_GPMI_ALE__GPIO_0_26 */
+   0x01b3 /* 
MX28_PAD_GPMI_CLE__GPIO_0_27 */
+   ;
+   fsl,drive-strength = 1;
+   fsl,voltage = 1;
+   fsl,pull-up = 1;
+   };
+
+   lcdif_pins_cfa10058: lcdif-evk@0 {
+   reg = 0;
+   fsl,pinmux-ids = 
+   0x1181 /* 
MX28_PAD_LCD_RD_E__LCD_VSYNC */
+   0x1191 /* 
MX28_PAD_LCD_WR_RWN__LCD_HSYNC */
+   0x11a1 /* 
MX28_PAD_LCD_RS__LCD_DOTCLK */
+   0x11b1

[PATCH 0/3] ARM: mxs: Various Crystalfontz DT additions

2013-06-26 Thread Alexandre Belloni
Hi,

This patch series add DT for the Crystalfontz CFA-10056 and Crystalfontz
CFA-10058.

The first patch simplifies board detection in mach-mxs.c as suggested by Thomas
Petazzoni in his review of the precedent DT additions.

The next patches are ading the DTs.

Thanks,
Alexandre

Alexandre Belloni (1):
  ARM: mxs: Simplify detection of CrystalFontz boards

Brian Lilly (2):
  ARM: mxs: dt: Add Crystalfontz CFA-10056 device tree
  ARM: mxs: dt: Add Crystalfontz CFA-10058 device tree

 arch/arm/boot/dts/Makefile   |   2 +
 arch/arm/boot/dts/imx28-cfa10056.dts | 200 +++
 arch/arm/boot/dts/imx28-cfa10058.dts | 183 
 arch/arm/mach-mxs/mach-mxs.c |   5 +-
 4 files changed, 386 insertions(+), 4 deletions(-)
 create mode 100644 arch/arm/boot/dts/imx28-cfa10056.dts
 create mode 100644 arch/arm/boot/dts/imx28-cfa10058.dts

-- 
1.8.1.2

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 1/3] ARM: mxs: Simplify detection of CrystalFontz boards

2013-06-26 Thread Alexandre Belloni
As all CrystalFontz boards are compatible with crystalfontz,cfa10036, make it
easier to add future boards.

Signed-off-by: Alexandre Belloni alexandre.bell...@free-electrons.com
---
 arch/arm/mach-mxs/mach-mxs.c | 5 +
 1 file changed, 1 insertion(+), 4 deletions(-)

diff --git a/arch/arm/mach-mxs/mach-mxs.c b/arch/arm/mach-mxs/mach-mxs.c
index 77280c6..8be23cb 100644
--- a/arch/arm/mach-mxs/mach-mxs.c
+++ b/arch/arm/mach-mxs/mach-mxs.c
@@ -363,10 +363,7 @@ static void __init mxs_machine_init(void)
imx28_evk_init();
else if (of_machine_is_compatible(bluegiga,apx4devkit))
apx4devkit_init();
-   else if (of_machine_is_compatible(crystalfontz,cfa10037) ||
-of_machine_is_compatible(crystalfontz,cfa10049) ||
-of_machine_is_compatible(crystalfontz,cfa10055) ||
-of_machine_is_compatible(crystalfontz,cfa10057))
+   else if (of_machine_is_compatible(crystalfontz,cfa10036))
crystalfontz_init();
 
of_platform_populate(NULL, of_default_bus_match_table,
-- 
1.8.1.2

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCHv2 1/3] ARM: mxs: Simplify detection of CrystalFontz boards

2013-06-26 Thread Alexandre Belloni
As all CrystalFontz boards are compatible with crystalfontz,cfa10036, make it
easier to add future boards.

Signed-off-by: Alexandre Belloni alexandre.bell...@free-electrons.com
---
 arch/arm/mach-mxs/mach-mxs.c | 5 +
 1 file changed, 1 insertion(+), 4 deletions(-)

diff --git a/arch/arm/mach-mxs/mach-mxs.c b/arch/arm/mach-mxs/mach-mxs.c
index 77280c6..8be23cb 100644
--- a/arch/arm/mach-mxs/mach-mxs.c
+++ b/arch/arm/mach-mxs/mach-mxs.c
@@ -363,10 +363,7 @@ static void __init mxs_machine_init(void)
imx28_evk_init();
else if (of_machine_is_compatible(bluegiga,apx4devkit))
apx4devkit_init();
-   else if (of_machine_is_compatible(crystalfontz,cfa10037) ||
-of_machine_is_compatible(crystalfontz,cfa10049) ||
-of_machine_is_compatible(crystalfontz,cfa10055) ||
-of_machine_is_compatible(crystalfontz,cfa10057))
+   else if (of_machine_is_compatible(crystalfontz,cfa10036))
crystalfontz_init();
 
of_platform_populate(NULL, of_default_bus_match_table,
-- 
1.8.1.2

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCHv2 0/3] ARM: mxs: Various Crystalfontz DT additions

2013-06-26 Thread Alexandre Belloni
Hi,

This patch series add DT for the Crystalfontz CFA-10056 and Crystalfontz
CFA-10058.

The first patch simplifies board detection in mach-mxs.c as suggested by Thomas
Petazzoni in his review of the precedent DT additions.

The next patches are ading the DTs.

Changes in v2:
 - took into account the review from Maxime Ripard

Thanks,
Alexandre

Alexandre Belloni (1):
  ARM: mxs: Simplify detection of CrystalFontz boards

Brian Lilly (2):
  ARM: mxs: dt: Add Crystalfontz CFA-10056 device tree
  ARM: mxs: dt: Add Crystalfontz CFA-10058 device tree

 arch/arm/boot/dts/Makefile   |   2 +
 arch/arm/boot/dts/imx28-cfa10056.dts | 171 +++
 arch/arm/boot/dts/imx28-cfa10058.dts | 158 
 arch/arm/mach-mxs/mach-mxs.c |   5 +-
 4 files changed, 332 insertions(+), 4 deletions(-)
 create mode 100644 arch/arm/boot/dts/imx28-cfa10056.dts
 create mode 100644 arch/arm/boot/dts/imx28-cfa10058.dts

-- 
1.8.1.2

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCHv2 2/3] ARM: mxs: dt: Add Crystalfontz CFA-10056 device tree

2013-06-26 Thread Alexandre Belloni
From: Brian Lilly br...@crystalfontz.com

The CFA-10056 is a breakout board for the CFA-10036, and is
basically a CFA-10037, with a 4.3 screen.

Signed-off-by: Brian Lilly br...@crystalfontz.com
Signed-off-by: Alexandre Belloni alexandre.bell...@free-electrons.com
---
 arch/arm/boot/dts/Makefile   |   1 +
 arch/arm/boot/dts/imx28-cfa10056.dts | 171 +++
 2 files changed, 172 insertions(+)
 create mode 100644 arch/arm/boot/dts/imx28-cfa10056.dts

diff --git a/arch/arm/boot/dts/Makefile b/arch/arm/boot/dts/Makefile
index 225d939..d494f37 100644
--- a/arch/arm/boot/dts/Makefile
+++ b/arch/arm/boot/dts/Makefile
@@ -131,6 +131,7 @@ dtb-$(CONFIG_ARCH_MXS) += imx23-evk.dtb \
imx28-cfa10037.dtb \
imx28-cfa10049.dtb \
imx28-cfa10055.dtb \
+   imx28-cfa10056.dtb \
imx28-cfa10057.dtb \
imx28-evk.dtb \
imx28-m28evk.dtb \
diff --git a/arch/arm/boot/dts/imx28-cfa10056.dts 
b/arch/arm/boot/dts/imx28-cfa10056.dts
new file mode 100644
index 000..dd6d217
--- /dev/null
+++ b/arch/arm/boot/dts/imx28-cfa10056.dts
@@ -0,0 +1,171 @@
+/*
+ * Copyright 2013 Free Electrons
+ *
+ * The code contained herein is licensed under the GNU General Public
+ * License. You may obtain a copy of the GNU General Public License
+ * Version 2 or later at the following locations:
+ *
+ * http://www.opensource.org/licenses/gpl-license.html
+ * http://www.gnu.org/copyleft/gpl.html
+ */
+
+/*
+ * The CFA-10056 is an expansion board for the CFA-10036 module, thus we
+ * need to include the CFA-10036 DTS.
+ */
+/include/ imx28-cfa10036.dts
+
+/ {
+   model = Crystalfontz CFA-10056 Board;
+   compatible = crystalfontz,cfa10056, crystalfontz,cfa10036, 
fsl,imx28;
+
+   apb@8000 {
+   apbh@8000 {
+   pinctrl@80018000 {
+   pinctrl-names = default, default;
+   pinctrl-1 = hog_pins_cfa10056
+   hog_pins_cfa10056_pullup;
+
+   hog_pins_cfa10056: hog-10056@0 {
+   reg = 0;
+   fsl,pinmux-ids = 
+   0x0073 /* 
MX28_PAD_GPMI_D7__GPIO_0_7 */
+   0x2153 /* 
MX28_PAD_SSP2_D5__GPIO_2_21 */
+   0x3053 /* 
MX28_PAD_AUART1_TX__GPIO_3_5 */
+   ;
+   fsl,drive-strength = 0;
+   fsl,voltage = 1;
+   fsl,pull-up = 0;
+   };
+
+   hog_pins_cfa10056_pullup: hog-10056-pullup@0 {
+   reg = 0;
+   fsl,pinmux-ids = 
+   0x31e3 /* 
MX28_PAD_LCD_RESET__GPIO_3_30 */
+   ;
+   fsl,drive-strength = 0;
+   fsl,voltage = 1;
+   fsl,pull-up = 1;
+   };
+
+   spi2_pins_cfa10056: spi2-cfa10056@0 {
+   reg = 0;
+   fsl,pinmux-ids = 
+   0x2103 /* 
MX28_PAD_SSP2_SCK__GPIO_2_16 */
+   0x2113 /* 
MX28_PAD_SSP2_CMD__GPIO_2_17 */
+   0x2123 /* 
MX28_PAD_SSP2_D0__GPIO_2_18 */
+   ;
+   fsl,drive-strength = 1;
+   fsl,voltage = 1;
+   fsl,pull-up = 1;
+   };
+
+   lcdif_pins_cfa10056: lcdif-evk@0 {
+   reg = 0;
+   fsl,pinmux-ids = 
+   0x1181 /* 
MX28_PAD_LCD_RD_E__LCD_VSYNC */
+   0x1191 /* 
MX28_PAD_LCD_WR_RWN__LCD_HSYNC */
+   0x11a1 /* 
MX28_PAD_LCD_RS__LCD_DOTCLK */
+   0x11b1 /* 
MX28_PAD_LCD_CS__LCD_ENABLE */
+   ;
+   fsl,drive-strength = 0;
+   fsl,voltage = 1;
+   fsl,pull-up = 0;
+   };
+   };
+
+   lcdif@8003 {
+   pinctrl-names = default;
+   pinctrl-0 = lcdif_24bit_pins_a

[PATCHv2 3/3] ARM: mxs: dt: Add Crystalfontz CFA-10058 device tree

2013-06-26 Thread Alexandre Belloni
From: Brian Lilly br...@crystalfontz.com

The CFA-10057 is a breakout board for the CFA-10036 that has Ethernet, USB and a
5 LCD screen on it.

Signed-off-by: Brian Lilly br...@crystalfontz.com
Signed-off-by: Alexandre Belloni alexandre.bell...@free-electrons.com
---
 arch/arm/boot/dts/Makefile   |   1 +
 arch/arm/boot/dts/imx28-cfa10058.dts | 158 +++
 2 files changed, 159 insertions(+)
 create mode 100644 arch/arm/boot/dts/imx28-cfa10058.dts

diff --git a/arch/arm/boot/dts/Makefile b/arch/arm/boot/dts/Makefile
index d494f37..ddd6f32 100644
--- a/arch/arm/boot/dts/Makefile
+++ b/arch/arm/boot/dts/Makefile
@@ -133,6 +133,7 @@ dtb-$(CONFIG_ARCH_MXS) += imx23-evk.dtb \
imx28-cfa10055.dtb \
imx28-cfa10056.dtb \
imx28-cfa10057.dtb \
+   imx28-cfa10058.dtb \
imx28-evk.dtb \
imx28-m28evk.dtb \
imx28-sps1.dtb \
diff --git a/arch/arm/boot/dts/imx28-cfa10058.dts 
b/arch/arm/boot/dts/imx28-cfa10058.dts
new file mode 100644
index 000..99a21ac
--- /dev/null
+++ b/arch/arm/boot/dts/imx28-cfa10058.dts
@@ -0,0 +1,158 @@
+/*
+ * Copyright 2013 Crystalfontz America, Inc.
+ * Copyright 2013 Free Electrons
+ *
+ * The code contained herein is licensed under the GNU General Public
+ * License. You may obtain a copy of the GNU General Public License
+ * Version 2 or later at the following locations:
+ *
+ * http://www.opensource.org/licenses/gpl-license.html
+ * http://www.gnu.org/copyleft/gpl.html
+ */
+
+/*
+ * The CFA-10058 is an expansion board for the CFA-10036 module, thus we
+ * need to include the CFA-10036 DTS.
+ */
+/include/ imx28-cfa10036.dts
+
+/ {
+   model = Crystalfontz CFA-10058 Board;
+   compatible = crystalfontz,cfa10058, crystalfontz,cfa10036, 
fsl,imx28;
+
+   apb@8000 {
+   apbh@8000 {
+   pinctrl@80018000 {
+   pinctrl-names = default, default;
+   pinctrl-1 = hog_pins_cfa10058
+   hog_pins_cfa10058_pullup;
+
+   hog_pins_cfa10058: hog-10058@0 {
+   reg = 0;
+   fsl,pinmux-ids = 
+   0x0073 /* 
MX28_PAD_GPMI_D7__GPIO_0_7 */
+   0x3053 /* 
MX28_PAD_AUART1_TX__GPIO_3_5 */
+   ;
+   fsl,drive-strength = 0;
+   fsl,voltage = 1;
+   fsl,pull-up = 0;
+   };
+
+   spi3_pins_cfa10058: spi3-cfa10058@0 {
+   reg = 0;
+   fsl,pinmux-ids = 
+   0x0183 /* 
MX28_PAD_GPMI_RDN__GPIO_0_24 */
+   0x01c3 /* 
MX28_PAD_GPMI_RESETN__GPIO_0_28 */
+   0x0113 /* 
MX28_PAD_GPMI_CE1N__GPIO_0_17 */
+   0x01a3 /* 
MX28_PAD_GPMI_ALE__GPIO_0_26 */
+   0x01b3 /* 
MX28_PAD_GPMI_CLE__GPIO_0_27 */
+   ;
+   fsl,drive-strength = 1;
+   fsl,voltage = 1;
+   fsl,pull-up = 1;
+   };
+
+   lcdif_pins_cfa10058: lcdif-evk@0 {
+   reg = 0;
+   fsl,pinmux-ids = 
+   0x1181 /* 
MX28_PAD_LCD_RD_E__LCD_VSYNC */
+   0x1191 /* 
MX28_PAD_LCD_WR_RWN__LCD_HSYNC */
+   0x11a1 /* 
MX28_PAD_LCD_RS__LCD_DOTCLK */
+   0x11b1 /* 
MX28_PAD_LCD_CS__LCD_ENABLE */
+   ;
+   fsl,drive-strength = 0;
+   fsl,voltage = 1;
+   fsl,pull-up = 0;
+   };
+   };
+
+   lcdif@8003 {
+   pinctrl-names = default;
+   pinctrl-0 = lcdif_24bit_pins_a
+lcdif_pins_cfa10058;
+   display = display;
+   status = okay;
+
+   display: display {
+   bits-per-pixel = 32;
+   bus-width = 24;
+
+   display-timings

Re: [PATCHv2 1/3] net: phy: prevent linking breakage

2013-05-29 Thread Alexandre Belloni
Hi,

On 28/05/2013 22:09, David Miller wrote:

 This is the wrong way to go about this.

 If the arch code absolutely requires CONFIG_PHYLIB=y then express that
 dependency in the arch Kconfig.  The arch code in question should not
 be compiled at all if CONFIG_PHYLIB has an incompatible setting.
But that is making it impossible to compile a kernel without any network
stack for those platforms or we are going back to either enclosing the
calls to phy_register_fixup{,_for_uid,_for_id} with #ifdef CONFIG_PHYLIB
or if(IS_BUILTIN(CONFIG_PHYLIB)). And as you can see, it is quite error
prone and is done only done for 2 platforms on a total of 6. I believe
fixing that in phy.h is more foolproof.

Regards,

-- 
Alexandre Belloni, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH] ARM: at91: Fix link breakage when !CONFIG_PHY

2013-05-24 Thread Alexandre Belloni
Fixes:
arch/arm/mach-at91/built-in.o: In function `ksz9021rn_phy_fixup':
:(.text+0x1174): undefined reference to `mdiobus_write'
:(.text+0x1188): undefined reference to `mdiobus_write'
:(.text+0x119c): undefined reference to `mdiobus_write'
:(.text+0x11b0): undefined reference to `mdiobus_write'
arch/arm/mach-at91/built-in.o: In function `sama5_dt_device_init':
:(.init.text+0x1e34): undefined reference to
`phy_register_fixup_for_uid'

Signed-off-by: Alexandre Belloni alexandre.bell...@free-electrons.com
---
 arch/arm/mach-at91/board-dt-sama5.c | 4 
 1 file changed, 4 insertions(+)

diff --git a/arch/arm/mach-at91/board-dt-sama5.c 
b/arch/arm/mach-at91/board-dt-sama5.c
index 705305e..f510381 100644
--- a/arch/arm/mach-at91/board-dt-sama5.c
+++ b/arch/arm/mach-at91/board-dt-sama5.c
@@ -38,6 +38,7 @@ static void __init at91_dt_init_irq(void)
of_irq_init(irq_of_match);
 }
 
+#ifdef CONFIG_PHY
 static int ksz9021rn_phy_fixup(struct phy_device *phy)
 {
int value;
@@ -59,12 +60,15 @@ static int ksz9021rn_phy_fixup(struct phy_device *phy)
 
return 0;
 }
+#endif
 
 static void __init sama5_dt_device_init(void)
 {
+#ifdef CONFIG_PHY
if (of_machine_is_compatible(atmel,sama5d3xcm))
phy_register_fixup_for_uid(PHY_ID_KSZ9021, MICREL_PHY_ID_MASK,
ksz9021rn_phy_fixup);
+#endif
 
of_platform_populate(NULL, of_default_bus_match_table, NULL, NULL);
 }
-- 
1.8.1.2

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH] ARM: at91: Fix link breakage when !CONFIG_PHY

2013-05-25 Thread Alexandre Belloni
Hi,

Scrap that, I'll send a v2.

Regards

On 25/05/2013 00:19, Alexandre Belloni wrote:
 Fixes:
 arch/arm/mach-at91/built-in.o: In function `ksz9021rn_phy_fixup':
 :(.text+0x1174): undefined reference to `mdiobus_write'
 :(.text+0x1188): undefined reference to `mdiobus_write'
 :(.text+0x119c): undefined reference to `mdiobus_write'
 :(.text+0x11b0): undefined reference to `mdiobus_write'
 arch/arm/mach-at91/built-in.o: In function `sama5_dt_device_init':
 :(.init.text+0x1e34): undefined reference to
 `phy_register_fixup_for_uid'

 Signed-off-by: Alexandre Belloni alexandre.bell...@free-electrons.com
 ---
  arch/arm/mach-at91/board-dt-sama5.c | 4 
  1 file changed, 4 insertions(+)

 diff --git a/arch/arm/mach-at91/board-dt-sama5.c 
 b/arch/arm/mach-at91/board-dt-sama5.c
 index 705305e..f510381 100644
 --- a/arch/arm/mach-at91/board-dt-sama5.c
 +++ b/arch/arm/mach-at91/board-dt-sama5.c
 @@ -38,6 +38,7 @@ static void __init at91_dt_init_irq(void)
   of_irq_init(irq_of_match);
  }
  
 +#ifdef CONFIG_PHY
  static int ksz9021rn_phy_fixup(struct phy_device *phy)
  {
   int value;
 @@ -59,12 +60,15 @@ static int ksz9021rn_phy_fixup(struct phy_device *phy)
  
   return 0;
  }
 +#endif
  
  static void __init sama5_dt_device_init(void)
  {
 +#ifdef CONFIG_PHY
   if (of_machine_is_compatible(atmel,sama5d3xcm))
   phy_register_fixup_for_uid(PHY_ID_KSZ9021, MICREL_PHY_ID_MASK,
   ksz9021rn_phy_fixup);
 +#endif
  
   of_platform_populate(NULL, of_default_bus_match_table, NULL, NULL);
  }


-- 
Alexandre Belloni, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH v2] ARM: at91: Fix link breakage when !CONFIG_PHYLIB

2013-05-25 Thread Alexandre Belloni
Fixes:
arch/arm/mach-at91/built-in.o: In function `ksz9021rn_phy_fixup':
:(.text+0x1174): undefined reference to `mdiobus_write'
:(.text+0x1188): undefined reference to `mdiobus_write'
:(.text+0x119c): undefined reference to `mdiobus_write'
:(.text+0x11b0): undefined reference to `mdiobus_write'
arch/arm/mach-at91/built-in.o: In function `sama5_dt_device_init':
:(.init.text+0x1e34): undefined reference to `phy_register_fixup_for_uid'

when CONFIG_PHYLIB is not selected.
---
Changes in v2:
use IS_BUILTIN
use CONFIG_PHYLIB and not CONFIG_PHY


 arch/arm/mach-at91/board-dt-sama5.c | 22 --
 1 file changed, 12 insertions(+), 10 deletions(-)

diff --git a/arch/arm/mach-at91/board-dt-sama5.c 
b/arch/arm/mach-at91/board-dt-sama5.c
index 705305e..e9ce541 100644
--- a/arch/arm/mach-at91/board-dt-sama5.c
+++ b/arch/arm/mach-at91/board-dt-sama5.c
@@ -47,22 +47,24 @@ static int ksz9021rn_phy_fixup(struct phy_device *phy)
 #define GMII_ERCR  11
 #define GMII_ERDWR 12
 
-   /* Set delay values */
-   value = GMII_RCCPSR | 0x8000;
-   phy_write(phy, GMII_ERCR, value);
-   value = 0xF2F4;
-   phy_write(phy, GMII_ERDWR, value);
-   value = GMII_RRDPSR | 0x8000;
-   phy_write(phy, GMII_ERCR, value);
-   value = 0x;
-   phy_write(phy, GMII_ERDWR, value);
+   if (IS_BUILTIN(CONFIG_PHYLIB)) {
+   /* Set delay values */
+   value = GMII_RCCPSR | 0x8000;
+   phy_write(phy, GMII_ERCR, value);
+   value = 0xF2F4;
+   phy_write(phy, GMII_ERDWR, value);
+   value = GMII_RRDPSR | 0x8000;
+   phy_write(phy, GMII_ERCR, value);
+   value = 0x;
+   phy_write(phy, GMII_ERDWR, value);
+   }
 
return 0;
 }
 
 static void __init sama5_dt_device_init(void)
 {
-   if (of_machine_is_compatible(atmel,sama5d3xcm))
+   if (of_machine_is_compatible(atmel,sama5d3xcm)  
IS_BUILTIN(CONFIG_PHYLIB))
phy_register_fixup_for_uid(PHY_ID_KSZ9021, MICREL_PHY_ID_MASK,
ksz9021rn_phy_fixup);
 
-- 
1.8.1.2

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH v2] ARM: at91: Fix link breakage when !CONFIG_PHYLIB

2013-05-27 Thread Alexandre Belloni
On 27/05/2013 10:09, Ludovic Desroches wrote:
 On Sat, May 25, 2013 at 10:05:57PM +0200, Jean-Christophe PLAGNIOL-VILLARD 
 wrote:
 On 09:39 Sat 25 May , Alexandre Belloni wrote:
 Fixes:
 arch/arm/mach-at91/built-in.o: In function `ksz9021rn_phy_fixup':
 :(.text+0x1174): undefined reference to `mdiobus_write'
 :(.text+0x1188): undefined reference to `mdiobus_write'
 :(.text+0x119c): undefined reference to `mdiobus_write'
 :(.text+0x11b0): undefined reference to `mdiobus_write'
 arch/arm/mach-at91/built-in.o: In function `sama5_dt_device_init':
 :(.init.text+0x1e34): undefined reference to `phy_register_fixup_for_uid'

 when CONFIG_PHYLIB is not selected.
 Signed-off-by missing.

 Acked-by: Ludovic Desroches ludovic.desroc...@atmel.com


I'll send a v3...

 ---
 Changes in v2:
 use IS_BUILTIN
 use CONFIG_PHYLIB and not CONFIG_PHY

 I do not like this, I prefer we just drop the fixup by adding the dt support
 to the micrel phy as done for broadcom

 Yes it will be a better solution but we don't have it. Even if we add dt
 support for micrel phy it won't go into 3.10 so it has to be fixed before the
 release.

The fixup is also done like that on i.mx6. I think we'll have to stick
to that for now.

 if !PHYLIB just add an inline declaration of 
 phy_register_fixup_for_uid

 so gcc will drop ksz9021rn_phy_fixup automatically

By using IS_BUILTIN, gcc is already optimizing out the offeding lines,
else you would still get the linking error.


-- 
Alexandre Belloni, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH v3] ARM: at91: Fix link breakage when !CONFIG_PHYLIB

2013-05-27 Thread Alexandre Belloni
Fixes:
arch/arm/mach-at91/built-in.o: In function `ksz9021rn_phy_fixup':
:(.text+0x1174): undefined reference to `mdiobus_write'
:(.text+0x1188): undefined reference to `mdiobus_write'
:(.text+0x119c): undefined reference to `mdiobus_write'
:(.text+0x11b0): undefined reference to `mdiobus_write'
arch/arm/mach-at91/built-in.o: In function `sama5_dt_device_init':
:(.init.text+0x1e34): undefined reference to `phy_register_fixup_for_uid'

when CONFIG_PHYLIB is not selected.

Signed-off-by: Alexandre Belloni alexandre.bell...@free-electrons.com
Acked-by: Ludovic Desroches ludovic.desroc...@atmel.com
---
Changes in v3:
added SoB
added Acked-By

Changes in v2:
use IS_BUILTIN
use CONFIG_PHYLIB and not CONFIG_PHY

 arch/arm/mach-at91/board-dt-sama5.c | 22 --
 1 file changed, 12 insertions(+), 10 deletions(-)

diff --git a/arch/arm/mach-at91/board-dt-sama5.c 
b/arch/arm/mach-at91/board-dt-sama5.c
index 705305e..e9ce541 100644
--- a/arch/arm/mach-at91/board-dt-sama5.c
+++ b/arch/arm/mach-at91/board-dt-sama5.c
@@ -47,22 +47,24 @@ static int ksz9021rn_phy_fixup(struct phy_device *phy)
 #define GMII_ERCR  11
 #define GMII_ERDWR 12
 
-   /* Set delay values */
-   value = GMII_RCCPSR | 0x8000;
-   phy_write(phy, GMII_ERCR, value);
-   value = 0xF2F4;
-   phy_write(phy, GMII_ERDWR, value);
-   value = GMII_RRDPSR | 0x8000;
-   phy_write(phy, GMII_ERCR, value);
-   value = 0x;
-   phy_write(phy, GMII_ERDWR, value);
+   if (IS_BUILTIN(CONFIG_PHYLIB)) {
+   /* Set delay values */
+   value = GMII_RCCPSR | 0x8000;
+   phy_write(phy, GMII_ERCR, value);
+   value = 0xF2F4;
+   phy_write(phy, GMII_ERDWR, value);
+   value = GMII_RRDPSR | 0x8000;
+   phy_write(phy, GMII_ERCR, value);
+   value = 0x;
+   phy_write(phy, GMII_ERDWR, value);
+   }
 
return 0;
 }
 
 static void __init sama5_dt_device_init(void)
 {
-   if (of_machine_is_compatible(atmel,sama5d3xcm))
+   if (of_machine_is_compatible(atmel,sama5d3xcm)  
IS_BUILTIN(CONFIG_PHYLIB))
phy_register_fixup_for_uid(PHY_ID_KSZ9021, MICREL_PHY_ID_MASK,
ksz9021rn_phy_fixup);
 
-- 
1.8.1.2

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH v3] ARM: at91: Fix link breakage when !CONFIG_PHYLIB

2013-05-27 Thread Alexandre Belloni
On 27/05/2013 14:05, Nicolas Ferre wrote:
 On 27/05/2013 12:48, Alexandre Belloni :
 Fixes:
 arch/arm/mach-at91/built-in.o: In function `ksz9021rn_phy_fixup':
 :(.text+0x1174): undefined reference to `mdiobus_write'
 :(.text+0x1188): undefined reference to `mdiobus_write'
 :(.text+0x119c): undefined reference to `mdiobus_write'
 :(.text+0x11b0): undefined reference to `mdiobus_write'
 arch/arm/mach-at91/built-in.o: In function `sama5_dt_device_init':
 :(.init.text+0x1e34): undefined reference to
 `phy_register_fixup_for_uid'

 when CONFIG_PHYLIB is not selected.

 Signed-off-by: Alexandre Belloni alexandre.bell...@free-electrons.com
 Acked-by: Ludovic Desroches ludovic.desroc...@atmel.com
 ---
 Changes in v3:
 added SoB
 added Acked-By

 A v3 is not needed simply for this. Thanks, anyway!


It was not much and I have to stop forgetting my SoB ;)

 One question though: why not just add

 select PHYLIB

 In Kconfig entry:

  config MACH_SAMA5_DT

 ?


That would simply mean that you have to enable NET when using a SAMA5
which is not what every user will want.

Regards,

-- 
Alexandre Belloni, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH v3] ARM: at91: Fix link breakage when !CONFIG_PHYLIB

2013-05-27 Thread Alexandre Belloni
On 27/05/2013 13:26, Jean-Christophe PLAGNIOL-VILLARD wrote:
 On May 27, 2013, at 6:48 PM, Alexandre Belloni 
 alexandre.bell...@free-electrons.com wrote:

 Fixes:
 arch/arm/mach-at91/built-in.o: In function `ksz9021rn_phy_fixup':
 :(.text+0x1174): undefined reference to `mdiobus_write'
 :(.text+0x1188): undefined reference to `mdiobus_write'
 :(.text+0x119c): undefined reference to `mdiobus_write'
 :(.text+0x11b0): undefined reference to `mdiobus_write'
 arch/arm/mach-at91/built-in.o: In function `sama5_dt_device_init':
 :(.init.text+0x1e34): undefined reference to `phy_register_fixup_for_uid'

 when CONFIG_PHYLIB is not selected.

 Signed-off-by: Alexandre Belloni alexandre.bell...@free-electrons.com
 Acked-by: Ludovic Desroches ludovic.desroc...@atmel.com
 no for this change

 add an inline version of phy_register_fixup_for_uid

 this will do the same for every platform

I don't actually see the added value of doing that. Using IS_BUILTIN is
readable and ensure that you will definitely be able to link. The
functions will be optimized out and removed by gcc even when you have
CONFIG_PHYLIB=m.

 ---
 Changes in v3:
  added SoB
  added Acked-By

 Changes in v2:
  use IS_BUILTIN
  use CONFIG_PHYLIB and not CONFIG_PHY

 arch/arm/mach-at91/board-dt-sama5.c | 22 --
 1 file changed, 12 insertions(+), 10 deletions(-)

 diff --git a/arch/arm/mach-at91/board-dt-sama5.c 
 b/arch/arm/mach-at91/board-dt-sama5.c
 index 705305e..e9ce541 100644
 --- a/arch/arm/mach-at91/board-dt-sama5.c
 +++ b/arch/arm/mach-at91/board-dt-sama5.c
 @@ -47,22 +47,24 @@ static int ksz9021rn_phy_fixup(struct phy_device *phy)
 #define GMII_ERCR11
 #define GMII_ERDWR   12

 -/* Set delay values */
 -value = GMII_RCCPSR | 0x8000;
 -phy_write(phy, GMII_ERCR, value);
 -value = 0xF2F4;
 -phy_write(phy, GMII_ERDWR, value);
 -value = GMII_RRDPSR | 0x8000;
 -phy_write(phy, GMII_ERCR, value);
 -value = 0x;
 -phy_write(phy, GMII_ERDWR, value);
 +if (IS_BUILTIN(CONFIG_PHYLIB)) {
 +/* Set delay values */
 +value = GMII_RCCPSR | 0x8000;
 +phy_write(phy, GMII_ERCR, value);
 +value = 0xF2F4;
 +phy_write(phy, GMII_ERDWR, value);
 +value = GMII_RRDPSR | 0x8000;
 +phy_write(phy, GMII_ERCR, value);
 +value = 0x;
 +phy_write(phy, GMII_ERDWR, value);
 +}

  return 0;
 }

 static void __init sama5_dt_device_init(void)
 {
 -if (of_machine_is_compatible(atmel,sama5d3xcm))
 +if (of_machine_is_compatible(atmel,sama5d3xcm)  
 IS_BUILTIN(CONFIG_PHYLIB))
  phy_register_fixup_for_uid(PHY_ID_KSZ9021, MICREL_PHY_ID_MASK,
  ksz9021rn_phy_fixup);

 -- 
 1.8.1.2



-- 
Alexandre Belloni, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH v3] ARM: at91: Fix link breakage when !CONFIG_PHYLIB

2013-05-27 Thread Alexandre Belloni
On 27/05/2013 14:59, Jean-Christophe PLAGNIOL-VILLARD wrote:

 no will not as you do ifdef CONFIG_PHYLIB and if CONFIG_PHYLIB=m the macro is 
 defended

 we do this all the time in the kernel

 I add the IS_BUILTIN  co to be used when a simple inline is not sufficient

Ok, it took me a while to understand what you were trying to explain.
I'm sending a patch set now. I don't believe it will be taken in for
3.10 though.

Regards,

-- 
Alexandre Belloni, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 1/3] net: phy: prevent linking breakage

2013-05-27 Thread Alexandre Belloni
phy_register_fixup{,_for_uid,_for_id} are called from arch/, quite
often, there is no protection to check whether CONFIG_PHYLIB=y which is
the only case where this would work. Having phylib as a module or not
compiled at all will result in that kind of linking failure:

arch/arm/mach-at91/built-in.o: In function `ksz9021rn_phy_fixup':
:(.text+0x1174): undefined reference to `mdiobus_write'
:(.text+0x1188): undefined reference to `mdiobus_write'
:(.text+0x119c): undefined reference to `mdiobus_write'
:(.text+0x11b0): undefined reference to `mdiobus_write'
arch/arm/mach-at91/built-in.o: In function `sama5_dt_device_init':
:(.init.text+0x1e34): undefined reference to `phy_register_fixup_for_uid'

Signed-off-by: Alexandre Belloni alexandre.bell...@free-electrons.com
---
 drivers/net/phy/phy_device.c |  6 ++
 include/linux/phy.h  | 12 
 2 files changed, 18 insertions(+)

diff --git a/drivers/net/phy/phy_device.c b/drivers/net/phy/phy_device.c
index 3657b4a..df36367 100644
--- a/drivers/net/phy/phy_device.c
+++ b/drivers/net/phy/phy_device.c
@@ -64,6 +64,11 @@ static int phy_attach_direct(struct net_device *dev, struct 
phy_device *phydev,
 u32 flags, phy_interface_t interface);
 
 /*
+ *  phy_register_fixup{,_for_uid,_for_id} are called from arch/ so this won't
+ *  work unless phylib is compiled in the kernel.
+ */
+#ifdef CONFIG_PHYLIB
+/*
  * Creates a new phy_fixup and adds it to the list
  * @bus_id: A string which matches phydev-dev.bus_id (or PHY_ANY_ID)
  * @phy_uid: Used to match against phydev-phy_id (the UID of the PHY)
@@ -109,6 +114,7 @@ int phy_register_fixup_for_id(const char *bus_id,
return phy_register_fixup(bus_id, PHY_ANY_UID, 0x, run);
 }
 EXPORT_SYMBOL(phy_register_fixup_for_id);
+#endif /* CONFIG_PHYLIB */
 
 /*
  * Returns 1 if fixup matches phydev in bus_id and phy_uid.
diff --git a/include/linux/phy.h b/include/linux/phy.h
index 9e11039..3f998a6 100644
--- a/include/linux/phy.h
+++ b/include/linux/phy.h
@@ -556,12 +556,24 @@ int phy_start_interrupts(struct phy_device *phydev);
 void phy_print_status(struct phy_device *phydev);
 void phy_device_free(struct phy_device *phydev);
 
+/*
+ *  phy_register_fixup{,_for_uid,_for_id} are called from arch/ so this won't
+ *  work unless phylib is compiled in the kernel.
+ *  Defining stubs allows to prevent linking errors.
+ */
+#ifdef CONFIG_PHYLIB
 int phy_register_fixup(const char *bus_id, u32 phy_uid, u32 phy_uid_mask,
int (*run)(struct phy_device *));
 int phy_register_fixup_for_id(const char *bus_id,
int (*run)(struct phy_device *));
 int phy_register_fixup_for_uid(u32 phy_uid, u32 phy_uid_mask,
int (*run)(struct phy_device *));
+#else
+#define phy_register_fixup(a, b, c, d) do { } while (0)
+#define phy_register_fixup_for_id(a, b) do { } while (0)
+#define phy_register_fixup_for_uid(a, b, c) do { } while (0)
+#endif /* CONFIG_PHYLIB */
+
 int phy_scan_fixups(struct phy_device *phydev);
 
 int phy_init_eee(struct phy_device *phydev, bool clk_stop_enable);
-- 
1.8.1.2

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 3/3] arm: imx: don't check for CONFIG_PHYLIB as builtin

2013-05-27 Thread Alexandre Belloni
Signed-off-by: Alexandre Belloni alexandre.bell...@free-electrons.com
---
 arch/arm/mach-imx/mach-imx6q.c | 23 ++-
 1 file changed, 10 insertions(+), 13 deletions(-)

diff --git a/arch/arm/mach-imx/mach-imx6q.c b/arch/arm/mach-imx/mach-imx6q.c
index 5536fd8..91c3cfb 100644
--- a/arch/arm/mach-imx/mach-imx6q.c
+++ b/arch/arm/mach-imx/mach-imx6q.c
@@ -99,16 +99,14 @@ soft:
 /* For imx6q sabrelite board: set KSZ9021RN RGMII pad skew */
 static int ksz9021rn_phy_fixup(struct phy_device *phydev)
 {
-   if (IS_BUILTIN(CONFIG_PHYLIB)) {
-   /* min rx data delay */
-   phy_write(phydev, 0x0b, 0x8105);
-   phy_write(phydev, 0x0c, 0x);
-
-   /* max rx/tx clock delay, min rx/tx control delay */
-   phy_write(phydev, 0x0b, 0x8104);
-   phy_write(phydev, 0x0c, 0xf0f0);
-   phy_write(phydev, 0x0b, 0x104);
-   }
+   /* min rx data delay */
+   phy_write(phydev, 0x0b, 0x8105);
+   phy_write(phydev, 0x0c, 0x);
+
+   /* max rx/tx clock delay, min rx/tx control delay */
+   phy_write(phydev, 0x0b, 0x8104);
+   phy_write(phydev, 0x0c, 0xf0f0);
+   phy_write(phydev, 0x0b, 0x104);
 
return 0;
 }
@@ -139,9 +137,8 @@ put_clk:
 
 static void __init imx6q_sabrelite_init(void)
 {
-   if (IS_BUILTIN(CONFIG_PHYLIB))
-   phy_register_fixup_for_uid(PHY_ID_KSZ9021, MICREL_PHY_ID_MASK,
-   ksz9021rn_phy_fixup);
+   phy_register_fixup_for_uid(PHY_ID_KSZ9021, MICREL_PHY_ID_MASK,
+   ksz9021rn_phy_fixup);
imx6q_sabrelite_cko1_setup();
 }
 
-- 
1.8.1.2

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 0/3] net: phy: prevent linking breakage

2013-05-27 Thread Alexandre Belloni
There is a linking issue when using phy_register_fixup{,_for_uid,_for_id} and
CONFIG_PHYLIB is not a builtin:

arch/arm/mach-at91/built-in.o: In function `ksz9021rn_phy_fixup':
:(.text+0x1174): undefined reference to `mdiobus_write'
:(.text+0x1188): undefined reference to `mdiobus_write'
:(.text+0x119c): undefined reference to `mdiobus_write'
:(.text+0x11b0): undefined reference to `mdiobus_write'
arch/arm/mach-at91/built-in.o: In function `sama5_dt_device_init':
:(.init.text+0x1e34): undefined reference to `phy_register_fixup_for_uid'

This has been solved for arch/arm/mach-mxs/ and arch/arm/mach-imx/ by testing
IS_BUILTIN(CONFIG_PHYLIB) before calling the functions.

The first patch is an attempt at solving that issue globally.

The following patches remove the unnecessary IS_BUILTIN(CONFIG_PHYLIB) checks.

Quickly greping into the code shows that the issue may arise in:

arch/powerpc/platforms/85xx/mpc85xx_mds.c
arch/arm/mach-davinci/board-dm644x-evm.c
arch/arm/mach-orion5x/dns323-setup.c
arch/arm/mach-at91/board-dt-sama5.c

Alexandre Belloni (3):
  net: phy: prevent linking breakage
  arm: mxs: don't check for CONFIG_PHYLIB as builtin
  arm: imx: don't check for CONFIG_PHYLIB as builtin

 arch/arm/mach-imx/mach-imx6q.c | 23 ++-
 arch/arm/mach-mxs/mach-mxs.c   |  5 ++---
 drivers/net/phy/phy_device.c   |  6 ++
 include/linux/phy.h| 12 
 4 files changed, 30 insertions(+), 16 deletions(-)

-- 
1.8.1.2

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 2/3] arm: mxs: don't check for CONFIG_PHYLIB as builtin

2013-05-27 Thread Alexandre Belloni
Signed-off-by: Alexandre Belloni alexandre.bell...@free-electrons.com
---
 arch/arm/mach-mxs/mach-mxs.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/arch/arm/mach-mxs/mach-mxs.c b/arch/arm/mach-mxs/mach-mxs.c
index 5b62b64..91c2bd2 100644
--- a/arch/arm/mach-mxs/mach-mxs.c
+++ b/arch/arm/mach-mxs/mach-mxs.c
@@ -273,9 +273,8 @@ static void __init apx4devkit_init(void)
 {
enable_clk_enet_out();
 
-   if (IS_BUILTIN(CONFIG_PHYLIB))
-   phy_register_fixup_for_uid(PHY_ID_KSZ8051, MICREL_PHY_ID_MASK,
-  apx4devkit_phy_fixup);
+   phy_register_fixup_for_uid(PHY_ID_KSZ8051, MICREL_PHY_ID_MASK,
+   apx4devkit_phy_fixup);
 }
 
 #define ENET0_MDC__GPIO_4_0MXS_GPIO_NR(4, 0)
-- 
1.8.1.2

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH 1/3] net: phy: prevent linking breakage

2013-05-27 Thread Alexandre Belloni
On 27/05/2013 18:39, Sascha Hauer wrote:
 On Mon, May 27, 2013 at 06:18:42PM +0200, Alexandre Belloni wrote:
 phy_register_fixup{,_for_uid,_for_id} are called from arch/, quite
 often, there is no protection to check whether CONFIG_PHYLIB=y which is
 the only case where this would work. Having phylib as a module or not
 compiled at all will result in that kind of linking failure:

 arch/arm/mach-at91/built-in.o: In function `ksz9021rn_phy_fixup':
 :(.text+0x1174): undefined reference to `mdiobus_write'
 :(.text+0x1188): undefined reference to `mdiobus_write'
 :(.text+0x119c): undefined reference to `mdiobus_write'
 :(.text+0x11b0): undefined reference to `mdiobus_write'
 arch/arm/mach-at91/built-in.o: In function `sama5_dt_device_init':
 :(.init.text+0x1e34): undefined reference to `phy_register_fixup_for_uid'

 Signed-off-by: Alexandre Belloni alexandre.bell...@free-electrons.com
 ---
  drivers/net/phy/phy_device.c |  6 ++
  include/linux/phy.h  | 12 
  2 files changed, 18 insertions(+)

 diff --git a/drivers/net/phy/phy_device.c b/drivers/net/phy/phy_device.c
 index 3657b4a..df36367 100644
 --- a/drivers/net/phy/phy_device.c
 +++ b/drivers/net/phy/phy_device.c
 @@ -64,6 +64,11 @@ static int phy_attach_direct(struct net_device *dev, 
 struct phy_device *phydev,
   u32 flags, phy_interface_t interface);
  
  /*
 + *  phy_register_fixup{,_for_uid,_for_id} are called from arch/ so this 
 won't
 + *  work unless phylib is compiled in the kernel.
 + */
 +#ifdef CONFIG_PHYLIB
 +/*
   * Creates a new phy_fixup and adds it to the list
   * @bus_id: A string which matches phydev-dev.bus_id (or PHY_ANY_ID)
   * @phy_uid: Used to match against phydev-phy_id (the UID of the PHY)
 @@ -109,6 +114,7 @@ int phy_register_fixup_for_id(const char *bus_id,
  return phy_register_fixup(bus_id, PHY_ANY_UID, 0x, run);
  }
  EXPORT_SYMBOL(phy_register_fixup_for_id);
 +#endif /* CONFIG_PHYLIB */
  
  /*
   * Returns 1 if fixup matches phydev in bus_id and phy_uid.
 diff --git a/include/linux/phy.h b/include/linux/phy.h
 index 9e11039..3f998a6 100644
 --- a/include/linux/phy.h
 +++ b/include/linux/phy.h
 @@ -556,12 +556,24 @@ int phy_start_interrupts(struct phy_device *phydev);
  void phy_print_status(struct phy_device *phydev);
  void phy_device_free(struct phy_device *phydev);
  
 +/*
 + *  phy_register_fixup{,_for_uid,_for_id} are called from arch/ so this 
 won't
 + *  work unless phylib is compiled in the kernel.
 + *  Defining stubs allows to prevent linking errors.
 + */
 +#ifdef CONFIG_PHYLIB
  int phy_register_fixup(const char *bus_id, u32 phy_uid, u32 phy_uid_mask,
  int (*run)(struct phy_device *));
  int phy_register_fixup_for_id(const char *bus_id,
  int (*run)(struct phy_device *));
  int phy_register_fixup_for_uid(u32 phy_uid, u32 phy_uid_mask,
  int (*run)(struct phy_device *));
 +#else
 +#define phy_register_fixup(a, b, c, d) do { } while (0)
 +#define phy_register_fixup_for_id(a, b) do { } while (0)
 +#define phy_register_fixup_for_uid(a, b, c) do { } while (0)
 Use static inline functions here. This breaks if someone does result
 checking on the functions which then expands to ret = do {} while (0);
 Also we still have type safety for !CONFIG_PHYLIB.

Right, I tried that first but forgot static so I had issues with
redefinition of the functions. I even played with __weak at some point...

I'll wait a bit for comments before sending v2.

-- 
Alexandre Belloni, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCHv2 0/3] net: phy: prevent linking breakage

2013-05-28 Thread Alexandre Belloni
There is a linking issue when using phy_register_fixup{,_for_uid,_for_id} and
CONFIG_PHYLIB is not a builtin:

arch/arm/mach-at91/built-in.o: In function `ksz9021rn_phy_fixup':
:(.text+0x1174): undefined reference to `mdiobus_write'
:(.text+0x1188): undefined reference to `mdiobus_write'
:(.text+0x119c): undefined reference to `mdiobus_write'
:(.text+0x11b0): undefined reference to `mdiobus_write'
arch/arm/mach-at91/built-in.o: In function `sama5_dt_device_init':
:(.init.text+0x1e34): undefined reference to `phy_register_fixup_for_uid'

This has been solved for arch/arm/mach-mxs/ and arch/arm/mach-imx/ by testing
IS_BUILTIN(CONFIG_PHYLIB) before calling the functions.

The first patch is an attempt at solving that issue globally.

The following patches remove the unnecessary IS_BUILTIN(CONFIG_PHYLIB) checks.

Quickly greping into the code shows that the issue may arise in:

arch/powerpc/platforms/85xx/mpc85xx_mds.c
arch/arm/mach-davinci/board-dm644x-evm.c
arch/arm/mach-orion5x/dns323-setup.c
arch/arm/mach-at91/board-dt-sama5.c

Changes in v2:
 - indentation fixes
 - use static inline function instead of defines and return -ENOTSUPP

Alexandre Belloni (3):
  net: phy: prevent linking breakage
  arm: mxs: don't check for CONFIG_PHYLIB as builtin
  arm: imx: don't check for CONFIG_PHYLIB as builtin

 arch/arm/mach-imx/mach-imx6q.c | 23 ++-
 arch/arm/mach-mxs/mach-mxs.c   |  5 ++---
 drivers/net/phy/phy_device.c   |  6 ++
 include/linux/phy.h| 26 ++
 4 files changed, 44 insertions(+), 16 deletions(-)

-- 
1.8.1.2

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCHv2 3/3] arm: imx: don't check for CONFIG_PHYLIB as builtin

2013-05-28 Thread Alexandre Belloni
Signed-off-by: Alexandre Belloni alexandre.bell...@free-electrons.com
---
 arch/arm/mach-imx/mach-imx6q.c | 23 ++-
 1 file changed, 10 insertions(+), 13 deletions(-)

diff --git a/arch/arm/mach-imx/mach-imx6q.c b/arch/arm/mach-imx/mach-imx6q.c
index 5536fd8..9094849 100644
--- a/arch/arm/mach-imx/mach-imx6q.c
+++ b/arch/arm/mach-imx/mach-imx6q.c
@@ -99,16 +99,14 @@ soft:
 /* For imx6q sabrelite board: set KSZ9021RN RGMII pad skew */
 static int ksz9021rn_phy_fixup(struct phy_device *phydev)
 {
-   if (IS_BUILTIN(CONFIG_PHYLIB)) {
-   /* min rx data delay */
-   phy_write(phydev, 0x0b, 0x8105);
-   phy_write(phydev, 0x0c, 0x);
-
-   /* max rx/tx clock delay, min rx/tx control delay */
-   phy_write(phydev, 0x0b, 0x8104);
-   phy_write(phydev, 0x0c, 0xf0f0);
-   phy_write(phydev, 0x0b, 0x104);
-   }
+   /* min rx data delay */
+   phy_write(phydev, 0x0b, 0x8105);
+   phy_write(phydev, 0x0c, 0x);
+
+   /* max rx/tx clock delay, min rx/tx control delay */
+   phy_write(phydev, 0x0b, 0x8104);
+   phy_write(phydev, 0x0c, 0xf0f0);
+   phy_write(phydev, 0x0b, 0x104);
 
return 0;
 }
@@ -139,9 +137,8 @@ put_clk:
 
 static void __init imx6q_sabrelite_init(void)
 {
-   if (IS_BUILTIN(CONFIG_PHYLIB))
-   phy_register_fixup_for_uid(PHY_ID_KSZ9021, MICREL_PHY_ID_MASK,
-   ksz9021rn_phy_fixup);
+   phy_register_fixup_for_uid(PHY_ID_KSZ9021, MICREL_PHY_ID_MASK,
+  ksz9021rn_phy_fixup);
imx6q_sabrelite_cko1_setup();
 }
 
-- 
1.8.1.2

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCHv2 2/3] arm: mxs: don't check for CONFIG_PHYLIB as builtin

2013-05-28 Thread Alexandre Belloni
Signed-off-by: Alexandre Belloni alexandre.bell...@free-electrons.com
---
 arch/arm/mach-mxs/mach-mxs.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/arch/arm/mach-mxs/mach-mxs.c b/arch/arm/mach-mxs/mach-mxs.c
index 5b62b64..2dad553 100644
--- a/arch/arm/mach-mxs/mach-mxs.c
+++ b/arch/arm/mach-mxs/mach-mxs.c
@@ -273,9 +273,8 @@ static void __init apx4devkit_init(void)
 {
enable_clk_enet_out();
 
-   if (IS_BUILTIN(CONFIG_PHYLIB))
-   phy_register_fixup_for_uid(PHY_ID_KSZ8051, MICREL_PHY_ID_MASK,
-  apx4devkit_phy_fixup);
+   phy_register_fixup_for_uid(PHY_ID_KSZ8051, MICREL_PHY_ID_MASK,
+  apx4devkit_phy_fixup);
 }
 
 #define ENET0_MDC__GPIO_4_0MXS_GPIO_NR(4, 0)
-- 
1.8.1.2

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCHv2 1/3] net: phy: prevent linking breakage

2013-05-28 Thread Alexandre Belloni
phy_register_fixup{,_for_uid,_for_id} are called from arch/, quite
often, there is no protection to check whether CONFIG_PHYLIB=y which is
the only case where this would work. Having phylib as a module or not
compiled at all will result in that kind of linking failure:

arch/arm/mach-at91/built-in.o: In function `ksz9021rn_phy_fixup':
:(.text+0x1174): undefined reference to `mdiobus_write'
:(.text+0x1188): undefined reference to `mdiobus_write'
:(.text+0x119c): undefined reference to `mdiobus_write'
:(.text+0x11b0): undefined reference to `mdiobus_write'
arch/arm/mach-at91/built-in.o: In function `sama5_dt_device_init':
:(.init.text+0x1e34): undefined reference to `phy_register_fixup_for_uid'

Signed-off-by: Alexandre Belloni alexandre.bell...@free-electrons.com
---
 drivers/net/phy/phy_device.c |  6 ++
 include/linux/phy.h  | 33 ++---
 2 files changed, 36 insertions(+), 3 deletions(-)

diff --git a/drivers/net/phy/phy_device.c b/drivers/net/phy/phy_device.c
index 3657b4a..df36367 100644
--- a/drivers/net/phy/phy_device.c
+++ b/drivers/net/phy/phy_device.c
@@ -64,6 +64,11 @@ static int phy_attach_direct(struct net_device *dev, struct 
phy_device *phydev,
 u32 flags, phy_interface_t interface);
 
 /*
+ *  phy_register_fixup{,_for_uid,_for_id} are called from arch/ so this won't
+ *  work unless phylib is compiled in the kernel.
+ */
+#ifdef CONFIG_PHYLIB
+/*
  * Creates a new phy_fixup and adds it to the list
  * @bus_id: A string which matches phydev-dev.bus_id (or PHY_ANY_ID)
  * @phy_uid: Used to match against phydev-phy_id (the UID of the PHY)
@@ -109,6 +114,7 @@ int phy_register_fixup_for_id(const char *bus_id,
return phy_register_fixup(bus_id, PHY_ANY_UID, 0x, run);
 }
 EXPORT_SYMBOL(phy_register_fixup_for_id);
+#endif /* CONFIG_PHYLIB */
 
 /*
  * Returns 1 if fixup matches phydev in bus_id and phy_uid.
diff --git a/include/linux/phy.h b/include/linux/phy.h
index 9e11039..2cc3383 100644
--- a/include/linux/phy.h
+++ b/include/linux/phy.h
@@ -556,12 +556,39 @@ int phy_start_interrupts(struct phy_device *phydev);
 void phy_print_status(struct phy_device *phydev);
 void phy_device_free(struct phy_device *phydev);
 
+/*
+ *  phy_register_fixup{,_for_uid,_for_id} are called from arch/ so this won't
+ *  work unless phylib is compiled in the kernel.
+ *  Defining stubs allows to prevent linking errors.
+ */
+#ifdef CONFIG_PHYLIB
 int phy_register_fixup(const char *bus_id, u32 phy_uid, u32 phy_uid_mask,
-   int (*run)(struct phy_device *));
+  int (*run)(struct phy_device *));
 int phy_register_fixup_for_id(const char *bus_id,
-   int (*run)(struct phy_device *));
+ int (*run)(struct phy_device *));
 int phy_register_fixup_for_uid(u32 phy_uid, u32 phy_uid_mask,
-   int (*run)(struct phy_device *));
+  int (*run)(struct phy_device *));
+#else
+static inline int phy_register_fixup(const char *bus_id, u32 phy_uid,
+u32 phy_uid_mask,
+int (*run)(struct phy_device *))
+{
+   return -ENOTSUPP;
+}
+
+static inline int phy_register_fixup_for_id(const char *bus_id,
+   int (*run)(struct phy_device *))
+{
+   return -ENOTSUPP;
+}
+
+static inline int phy_register_fixup_for_uid(u32 phy_uid, u32 phy_uid_mask,
+int (*run)(struct phy_device *))
+{
+   return -ENOTSUPP;
+}
+#endif /* CONFIG_PHYLIB */
+
 int phy_scan_fixups(struct phy_device *phydev);
 
 int phy_init_eee(struct phy_device *phydev, bool clk_stop_enable);
-- 
1.8.1.2

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH] mac802154: correct a typo in ieee802154_alloc_device() prototype

2013-10-21 Thread Alexandre Belloni
This has no other impact than a cosmetic one.

Signed-off-by: Alexandre Belloni alexandre.bell...@free-electrons.com
---
 include/net/mac802154.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/include/net/mac802154.h b/include/net/mac802154.h
index d0d11df..807d6b7 100644
--- a/include/net/mac802154.h
+++ b/include/net/mac802154.h
@@ -133,7 +133,7 @@ struct ieee802154_ops {
 
 /* Basic interface to register ieee802154 device */
 struct ieee802154_dev *
-ieee802154_alloc_device(size_t priv_data_lex, struct ieee802154_ops *ops);
+ieee802154_alloc_device(size_t priv_data_len, struct ieee802154_ops *ops);
 void ieee802154_free_device(struct ieee802154_dev *dev);
 int ieee802154_register_device(struct ieee802154_dev *dev);
 void ieee802154_unregister_device(struct ieee802154_dev *dev);
-- 
1.8.3.2

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH v2] PWM: atmel-pwm: use request/free instead of enable/disable

2013-10-09 Thread Alexandre Belloni

-BEGIN PGP SIGNED MESSAGE-
Hash: SHA256

On 08/10/2013 14:05, Thierry Reding wrote:
 On Mon, Sep 30, 2013 at 05:22:33PM +0200, Alexandre Belloni wrote:
 I found that disabling a pwm while it is at a low level will actually
put it
 back at a high level. The main symptom is that leds-pwm is calling
pwm_disable()
 after setting the duty cycle to 0. Hence, instead of getting a
switched off LED,
 you get an LED lit up at full brightness.

 I wonder why that's the case. What's causing the PWM to go back to full
 duty cycle when disabled? There was a similar issue with some other PWM
 driver a while back and the cause was tracked down to be that you had to
 wait for a full period to make sure the signal was constantly low before
 switching off the clock. Perhaps something similar is the issue here?

I tried letting enabling/disabling the PWM channel in
pwm_enable/pwm_disable and enabling/disabling the clock in
pwm_request/pwm_free. The issue is still there.

- From the datasheet (also it seems something is fishy there, wrt CPOL):

Waveforms are fixed at 0 when:
- - CDTY = CPRD and CPOL = 0
- - CDTY = 0 and CPOL = 1
Waveforms are fixed at 1 (once the channel is enabled) when:
- - CDTY = 0 and CPOL = 0
- - CDTY = CPRD and CPOL = 1
The waveform polarity must be set before enabling the channel. This
immediately affects the channel output level.

So, while I agree with you that it makes us keep the pwm clock enabled
forever, it makes me believe that we have to let the PWM enabled to get
that working correctly.


I also tried changing the polarity and setting pull down on the pin but
the level seems to be driven high. One thing that is working though is
setting the override value before disabling the PWM. Then the level that
is set is still kept when the pwm is disabled. Unfortunately, that
feature is only available since the sama5.


 Solve that by using the request and free callbacks to enable and
disable the
 pwm channels and the clock.

 pwm - PWM,  please.

 diff --git a/drivers/pwm/pwm-atmel.c b/drivers/pwm/pwm-atmel.c
 [...]
 +static int atmel_pwm_enable(struct pwm_chip *chip, struct pwm_device
*pwm)
 +{
 +/*
 + * This is a dummy function, required to be able to register the pwm
 + * chip, see pwmadd_chip() in pwm/core.c
 + */
 +return 0;
 +}
 +
 +static void atmel_pwm_disable(struct pwm_chip *chip, struct
pwm_device *pwm)
 +{
 +/*
 + * This is a dummy function, required to be able to register the pwm
 + * chip, see pwmadd_chip() in pwm/core.c
 + */
 +}

 This just doesn't feel right. Can somebody please investigate what the
 real reason is for the behaviour described in the commit message and see
 if we can't solve this in some other way? .request() and .free() are
 typically called very early or very late, respectively, so this patch
 will keep the PWM clock on forever (pretty much).

 Thierry


- -- 
Alexandre Belloni, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com
-BEGIN PGP SIGNATURE-
Version: GnuPG v1.4.12 (GNU/Linux)

iQIcBAEBCAAGBQJSVTqjAAoJEKbNnwlvZCyzzE4P/igeF8UBUPdEQAYpgG3avTTh
93oEGu8sHoNSbUJY6O51x5f+96QiwrZF62rjy4PO8BtHR6fGgUt94RtyMacut/aY
NfRwdwfe24wYwHNpwOCv9uD1ZtiLyD9wAMeIEsoYy57A9XPPuuTOmJamN7jzsh/K
OvjdmjWcJQPymSTABdus4Zt7ccIgPqMsai8HQYiNqnKbPDUXx20/+QH5Kw2hPxi0
YPK36xEeEW0pB+v9fVU54abAV3Bh4tEOIJ/7wqWeDxN9WBK8LEG20pb6ZNFI3GJO
KzEO7Y4fZzPc85RCPfigyyDnOvzHRP5vc1vfSIOxwPqhZLZL6ceBlCHWhAr+CYSU
mWtNruBP9dhJfRDKtchDv3D63YBDip4DTDh/0jiqT6Qw6LTjSU+bWi1RVlrpa6HY
Wv6siL0gy4USKk8DJEl/pWBi3SlSbPynT+sZLKrWpz2E3oLjgDNALPIZtMM38xYj
X7LzZX1v8t6psksnH13Q4yAgyuiIUcJWXTn7wMPZ70DhJ98JpcsV3o9kZQnGTN+A
sp9/pZTd/7sK5LzZx+aMnMItNLgWy85LRLfHzH2c3vAKETVVPx+Vqgojw0sWMC8E
U3oA71/nYOFUssCs9kzCNvU/n7p16bGxyPzbHH2D+2CowiFdYVwJhX1iT4TFTkQJ
ymqGpRABiFB6bmhf4WRg
=zebD
-END PGP SIGNATURE-

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCHv3 2/3] ARM: mxs: cfa10049: Switch bus i2c1 to bitbanging

2013-07-02 Thread Alexandre Belloni
On 02/07/2013 18:33, Marek Vasut wrote:
 Dear Alexandre Belloni,
 
 On 02/07/2013 13:50, Alexandre Belloni wrote:
 On 02/07/2013 13:45, Fabio Estevam wrote:
 Shouldn't this be

  i2c@1 {
  
  reg = 1; ?

 No, we have 4 devices on that mux and 2 pins to select the muxing.

 OK, got it working.

 So, the results:

 bitbanging:

 # time cat /sys/bus/iio/devices/iio\:device1/in_voltage0_raw
 2637
 real 0m 0.09s
 user 0m 0.01s
 sys  0m 0.01s


 i2c-mxs PIO mode:

 # time cat /sys/bus/iio/devices/iio\:device1/in_voltage0_raw
 [   35.007650] [sched_delayed] sched: RT throttling activated
 2627
 real 0m 7.14s
 user 0m 0.02s
 sys  0m 0.01s


 i2c-mxs PIO mode without LRADC:

 # time cat /sys/bus/iio/devices/iio\:device1/in_voltage0_raw
 [   18.007432] [sched_delayed] sched: RT throttling activated
 2629
 real 0m 7.09s
 user 0m 0.00s
 sys  0m 0.03s


 i2c-mxs DMA mode:

 # time cat /sys/bus/iio/devices/iio\:device1/in_voltage0_raw
 2631
 real 0m 0.12s
 user 0m 0.01s
 sys  0m 0.01s


 It seems fine for me.
 
 I think I'm getting a little lost in these gazilions of i2c and lradc 
 threads. 
 Can we not create one thread and keep the related stuff in there instead of 
 discussing it all around !?
 
 Only one question comes to mind with this email -- what do LRADC and I2C have 
 to 
 do with each other here ?
 

Yeah, sorry, I meant the lradc touchscreen support. This seemed to
trigger the issue for Fabio but as my testing shows, this is not the
case for me, I get the issue with PIO, whether the lradc touchscreen
support is activated or not.

I think Torsten is the one that investigated it the most :

http://www.spinics.net/lists/linux-i2c/msg12619.html


 It'd be nice if someone could summarize on what I should focus and possibly 
 prepare a testcase.
 

On my setup, it happens on every i2c read that are done in PIO mode.
But, my setup may be a bit unconventional as we are using a i2c gpio muxer.

Regards,

-- 
Alexandre Belloni, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH] i2c: mxs: Better error handling

2013-07-03 Thread Alexandre Belloni
This patch fixes two error handling cases in mxs_i2c_xfer_msg():

 - in PIO mode, mxs_i2c_pio_setup_xfer() may return an error but i2c-cmd_err
 will not be set so mxs_i2c_xfer_msg() fails silently.

 - in DMA mode, mxs_i2c_dma_setup_xfer() may return an error and have
 i2c-cmd_err set to -ENXIO. In that case, we want to go through the
 MXS_I2C_CTRL1_CLR_GOT_A_NAK before returning.

Signed-off-by: Alexandre Belloni alexandre.bell...@free-electrons.com
---
 drivers/i2c/busses/i2c-mxs.c | 6 --
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/i2c/busses/i2c-mxs.c b/drivers/i2c/busses/i2c-mxs.c
index 2039f23..92f22b0 100644
--- a/drivers/i2c/busses/i2c-mxs.c
+++ b/drivers/i2c/busses/i2c-mxs.c
@@ -502,7 +502,7 @@ static int mxs_i2c_xfer_msg(struct i2c_adapter *adap, 
struct i2c_msg *msg,
INIT_COMPLETION(i2c-cmd_complete);
ret = mxs_i2c_dma_setup_xfer(adap, msg, flags);
if (ret)
-   return ret;
+   goto exit;
 
ret = wait_for_completion_timeout(i2c-cmd_complete,
msecs_to_jiffies(1000));
@@ -510,6 +510,7 @@ static int mxs_i2c_xfer_msg(struct i2c_adapter *adap, 
struct i2c_msg *msg,
goto timeout;
}
 
+exit:
if (i2c-cmd_err == -ENXIO) {
/*
 * If the transfer fails with a NAK from the slave the
@@ -519,7 +520,8 @@ static int mxs_i2c_xfer_msg(struct i2c_adapter *adap, 
struct i2c_msg *msg,
   i2c-regs + MXS_I2C_CTRL1_SET);
}
 
-   ret = i2c-cmd_err;
+   if (i2c-cmd_err)
+   ret = i2c-cmd_err;
 
dev_dbg(i2c-dev, Done with err=%d\n, ret);
 
-- 
1.8.1.2

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCHv3 2/3] ARM: mxs: cfa10049: Switch bus i2c1 to bitbanging

2013-07-07 Thread Alexandre Belloni
On 06/07/2013 12:26, Jonathan Cameron wrote:
 On 06/24/2013 06:24 PM, Alexandre Belloni wrote:
 From: Maxime Ripard maxime.rip...@free-electrons.com

 The ADCs connected to this bus have been experiencing some timeout
 issues when using the iMX28 i2c controller. Switching back to bitbanging
 solves this.

 Signed-off-by: Maxime Ripard maxime.rip...@free-electrons.com
 Signed-off-by: Alexandre Belloni alexandre.bell...@free-electrons.com
 
 As there are no disadvantages in taking the driver through IIO and these 
 changes
 through the appropriate arch trees, I'd not propose to take these through IIO
 (even when the discussion is done) unless specifically asked to.
 

Sure, especially since, we may finally not move to i2c bitbanging. I'll
probably resend a new version of those patches separately.

Shawn, please wait for the i2c-mxs PIO/DMA mode discussion to end before
applying. If possible, I would prefer not using bitbanging.

Regards,


-- 
Alexandre Belloni, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCHv3 1/3] iio: Add Nuvoton NAU7802 ADC driver

2013-07-09 Thread Alexandre Belloni
Hi Jonathan,

I don't actually see it in iio.git on kernel.org, am I doing something
wrong ?

On 06/07/2013 12:24, Jonathan Cameron wrote:
 On 07/04/2013 10:08 AM, Lars-Peter Clausen wrote:
 On 06/24/2013 07:24 PM, Alexandre Belloni wrote:
 The Nuvoton NAU7802 ADC is a 24-bit 2-channels I2C ADC, with adjustable
 gain and sampling rates.

 Signed-off-by: Alexandre Belloni alexandre.bell...@free-electrons.com
 Signed-off-by: Maxime Ripard maxime.rip...@free-electrons.com
 Reviewed-by: Lars-Peter Clausen l...@metafoo.de

 Applied to the togreg branch of iio.git (with a few little tweaks).

 There was some fuzz that required manual fixing because of another driver 
 merge so
 please check I didn't foul anything up with this or the other bits below.

 There were two trivial missing unlocks on error paths in the read_raw 
 function that
 I've fixed up (Coccinelle found these for me - if you can I would always 
 advise
 running sparse, coccicheck and ideally smatch before submitting patches).

 I fixed up the comments because if there is one thing I hate bothering
 with it is delightful patches that just fix this stuff. Much better
 to do it now given it took 20 secs ;)

 One remark though. Multiline comments should be like

 /*
  * foo
  * bar
  */

 not

 /* foo
  * bar
  */

 But not need to resend the patch just for this

 - Lars



-- 
Alexandre Belloni, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


<    1   2   3   4   5   6   7   8   9   10   >