[PATCH 2/3] drm: exynos: hdmi: add exynos5 support to hdmi driver

2012-09-13 Thread Joonyoung Shim
Hi, Rahul.

Overall, i think this patch causes messy codes.

On 09/12/2012 09:08 PM, Rahul Sharma wrote:
> Added support for exynos5 to hdmi driver. Resource init
> is splitted for exynos5 and exynos4. Exynos5 hdmi driver
> is dt based while exynos4 hdmi driver is not.
>
> Signed-off-by: Rahul Sharma 
> Signed-off-by: Shirish S 
> Signed-off-by: Fahad Kunnathadi 
> ---
>   drivers/gpu/drm/exynos/exynos_hdmi.c |  300 
> ++
>   1 files changed, 269 insertions(+), 31 deletions(-)
>
> diff --git a/drivers/gpu/drm/exynos/exynos_hdmi.c 
> b/drivers/gpu/drm/exynos/exynos_hdmi.c
> index a6aea6f..5236256 100644
> --- a/drivers/gpu/drm/exynos/exynos_hdmi.c
> +++ b/drivers/gpu/drm/exynos/exynos_hdmi.c
> @@ -32,6 +32,9 @@
>   #include 
>   #include 
>   #include 
> +#include 
> +#include 
> +#include 
>   
>   #include 
>   
> @@ -61,11 +64,13 @@ struct hdmi_context {
>   boolpowered;
>   boolis_v13;
>   booldvi_mode;
> + boolis_soc_exynos5;
>   struct mutexhdmi_mutex;
>   
>   void __iomem*regs;
> - unsigned intexternal_irq;
> - unsigned intinternal_irq;
> + int external_irq;
> + int internal_irq;
> + int hpd_gpio;
>   
>   struct i2c_client   *ddc_port;
>   struct i2c_client   *hdmiphy_port;
> @@ -953,6 +958,23 @@ static inline void hdmi_reg_writemask(struct 
> hdmi_context *hdata,
>   writel(value, hdata->regs + reg_id);
>   }
>   
> +static void hdmi_cfg_hpd(struct hdmi_context *hdata, bool internal)
> +{
> + if (!internal) {
> + s3c_gpio_cfgpin(hdata->hpd_gpio, S3C_GPIO_SFN(0xf));
> + s3c_gpio_setpull(hdata->hpd_gpio, S3C_GPIO_PULL_DOWN);
> + } else {
> + s3c_gpio_cfgpin(hdata->hpd_gpio, S3C_GPIO_SFN(3));
> + s3c_gpio_setpull(hdata->hpd_gpio, S3C_GPIO_PULL_NONE);
> + }
> +}
> +

Don't use SoC specific functions in the driver.

> +static int hdmi_get_hpd(struct hdmi_context *hdata)
> +{
> + int gpio_stat = gpio_get_value(hdata->hpd_gpio);
> + return gpio_stat;
> +}
> +

Actually, above two functions should come from platform data, but these
will remove soon.

>   static void hdmi_v13_regs_dump(struct hdmi_context *hdata, char *prefix)
>   {
>   #define DUMPREG(reg_id) \
> @@ -2026,6 +2048,9 @@ static void hdmi_poweron(struct hdmi_context *hdata)
>   
>   if (hdata->cfg_hpd)
>   hdata->cfg_hpd(true);
> + else
> + hdmi_cfg_hpd(hdata, true);
> +
>   mutex_unlock(>hdmi_mutex);
>   
>   pm_runtime_get_sync(hdata->dev);
> @@ -2063,6 +2088,8 @@ static void hdmi_poweroff(struct hdmi_context *hdata)
>   mutex_lock(>hdmi_mutex);
>   if (hdata->cfg_hpd)
>   hdata->cfg_hpd(false);
> + else
> + hdmi_cfg_hpd(hdata, false);
>   
>   hdata->powered = false;
>   
> @@ -2110,17 +2137,16 @@ static irqreturn_t hdmi_external_irq_thread(int irq, 
> void *arg)
>   struct exynos_drm_hdmi_context *ctx = arg;
>   struct hdmi_context *hdata = ctx->ctx;
>   
> - if (!hdata->get_hpd)
> - goto out;
> -
>   mutex_lock(>hdmi_mutex);
> - hdata->hpd = hdata->get_hpd();
> + if (hdata->get_hpd)
> + hdata->hpd = hdata->get_hpd();
> + else
> + hdata->hpd = hdmi_get_hpd(hdata);
>   mutex_unlock(>hdmi_mutex);
>   
>   if (ctx->drm_dev)
>   drm_helper_hpd_irq_event(ctx->drm_dev);
>   
> -out:
>   return IRQ_HANDLED;
>   }
>   
> @@ -2203,23 +2229,25 @@ static int __devinit hdmi_resources_init(struct 
> hdmi_context *hdata)
>   
>   clk_set_parent(res->sclk_hdmi, res->sclk_pixel);
>   
> - res->regul_bulk = kzalloc(ARRAY_SIZE(supply) *
> - sizeof(res->regul_bulk[0]), GFP_KERNEL);
> - if (!res->regul_bulk) {
> - DRM_ERROR("failed to get memory for regulators\n");
> - goto fail;
> - }
> - for (i = 0; i < ARRAY_SIZE(supply); ++i) {
> - res->regul_bulk[i].supply = supply[i];
> - res->regul_bulk[i].consumer = NULL;
> - }
> - ret = regulator_bulk_get(dev, ARRAY_SIZE(supply), res->regul_bulk);
> - if (ret) {
> - DRM_ERROR("failed to get regulators\n");
> - goto fail;
> + if (!hdata->is_soc_exynos5) {
> + res->regul_bulk = kzalloc(ARRAY_SIZE(supply) *
> + sizeof(res->regul_bulk[0]), GFP_KERNEL);
> + if (!res->regul_bulk) {
> + DRM_ERROR("failed to get memory for regulators\n");
> + goto fail;
> + }
> + for (i = 0; i < ARRAY_SIZE(supply); ++i) {
> + 

[PATCH 2/3] drm: exynos: hdmi: add exynos5 support to hdmi driver

2012-09-13 Thread RAHUL SHARMA
> Hi, Rahul.
>
> Overall, i think this patch causes messy codes.
>
>
> On 09/12/2012 09:08 PM, Rahul Sharma wrote:
>>
>> Added support for exynos5 to hdmi driver. Resource init
>> is splitted for exynos5 and exynos4. Exynos5 hdmi driver
>> is dt based while exynos4 hdmi driver is not.
>>
>> Signed-off-by: Rahul Sharma 
>> Signed-off-by: Shirish S 
>> Signed-off-by: Fahad Kunnathadi 
>> ---
>>   drivers/gpu/drm/exynos/exynos_hdmi.c |  300
>> ++
>>   1 files changed, 269 insertions(+), 31 deletions(-)
>>
>> diff --git a/drivers/gpu/drm/exynos/exynos_hdmi.c
>> b/drivers/gpu/drm/exynos/exynos_hdmi.c
>> index a6aea6f..5236256 100644
>> --- a/drivers/gpu/drm/exynos/exynos_hdmi.c
>> +++ b/drivers/gpu/drm/exynos/exynos_hdmi.c
>> @@ -32,6 +32,9 @@
>>   #include 
>>   #include 
>>   #include 
>> +#include 
>> +#include 
>> +#include 
>> #include 
>>   @@ -61,11 +64,13 @@ struct hdmi_context {
>> boolpowered;
>> boolis_v13;
>> booldvi_mode;
>> +   boolis_soc_exynos5;
>> struct mutexhdmi_mutex;
>> void __iomem*regs;
>> -   unsigned intexternal_irq;
>> -   unsigned intinternal_irq;
>> +   int external_irq;
>> +   int internal_irq;
>> +   int hpd_gpio;
>> struct i2c_client   *ddc_port;
>> struct i2c_client   *hdmiphy_port;
>> @@ -953,6 +958,23 @@ static inline void hdmi_reg_writemask(struct
>> hdmi_context *hdata,
>> writel(value, hdata->regs + reg_id);
>>   }
>>   +static void hdmi_cfg_hpd(struct hdmi_context *hdata, bool internal)
>> +{
>> +   if (!internal) {
>> +   s3c_gpio_cfgpin(hdata->hpd_gpio, S3C_GPIO_SFN(0xf));
>> +   s3c_gpio_setpull(hdata->hpd_gpio, S3C_GPIO_PULL_DOWN);
>> +   } else {
>> +   s3c_gpio_cfgpin(hdata->hpd_gpio, S3C_GPIO_SFN(3));
>> +   s3c_gpio_setpull(hdata->hpd_gpio, S3C_GPIO_PULL_NONE);
>> +   }
>> +}
>> +
>
>
> Don't use SoC specific functions in the driver.
>
>
>> +static int hdmi_get_hpd(struct hdmi_context *hdata)
>> +{
>> +   int gpio_stat = gpio_get_value(hdata->hpd_gpio);
>> +   return gpio_stat;
>> +}
>> +
>
>
> Actually, above two functions should come from platform data, but these
> will remove soon.
>

I had no option to pass above function pointers through hdmi device tree node
in exynos5. I can still pass these pointers through plf data by searching the
DT node and initializing the platform data ptr in the Machine Init file 
(mach-ecynos5-dt.c)
which is again not recommended. 
I preferred this approach since many drivers LCD, eeprom, nand drivers 
configuring, getting
GPIO this way. One or the other way we have to go off-track.
Please give me your opinion.

>
>>   static void hdmi_v13_regs_dump(struct hdmi_context *hdata, char *prefix)
>>   {
>>   #define DUMPREG(reg_id) \
>> @@ -2026,6 +2048,9 @@ static void hdmi_poweron(struct hdmi_context *hdata)
>> if (hdata->cfg_hpd)
>> hdata->cfg_hpd(true);
>> +   else
>> +   hdmi_cfg_hpd(hdata, true);
>> +
>> mutex_unlock(>hdmi_mutex);
>> pm_runtime_get_sync(hdata->dev);
>> @@ -2063,6 +2088,8 @@ static void hdmi_poweroff(struct hdmi_context
>> *hdata)
>> mutex_lock(>hdmi_mutex);
>> if (hdata->cfg_hpd)
>> hdata->cfg_hpd(false);
>> +   else
>> +   hdmi_cfg_hpd(hdata, false);
>> hdata->powered = false;
>>   @@ -2110,17 +2137,16 @@ static irqreturn_t hdmi_external_irq_thread(int
>> irq, void *arg)
>> struct exynos_drm_hdmi_context *ctx = arg;
>> struct hdmi_context *hdata = ctx->ctx;
>>   - if (!hdata->get_hpd)
>> -   goto out;
>> -
>> mutex_lock(>hdmi_mutex);
>> -   hdata->hpd = hdata->get_hpd();
>> +   if (hdata->get_hpd)
>> +   hdata->hpd = hdata->get_hpd();
>> +   else
>> +   hdata->hpd = hdmi_get_hpd(hdata);
>> mutex_unlock(>hdmi_mutex);
>> if (ctx->drm_dev)
>> drm_helper_hpd_irq_event(ctx->drm_dev);
>>   -out:
>> return IRQ_HANDLED;
>>   }
>>   @@ -2203,23 +2229,25 @@ static int __devinit hdmi_resources_init(struct
>> hdmi_context *hdata)
>> clk_set_parent(res->sclk_hdmi, res->sclk_pixel);
>>   - res->regul_bulk = kzalloc(ARRAY_SIZE(supply) *
>> -   sizeof(res->regul_bulk[0]), GFP_KERNEL);
>> -   if (!res->regul_bulk) {
>> -   DRM_ERROR("failed to get memory for regulators\n");
>> -   goto fail;
>> -   }
>> -   for (i = 0; i < ARRAY_SIZE(supply); ++i) {
>> -   res->regul_bulk[i].supply = supply[i];
>> -  

Re: [PATCH 2/3] drm: exynos: hdmi: add exynos5 support to hdmi driver

2012-09-13 Thread RAHUL SHARMA
 Hi, Rahul.

 Overall, i think this patch causes messy codes.


 On 09/12/2012 09:08 PM, Rahul Sharma wrote:

 Added support for exynos5 to hdmi driver. Resource init
 is splitted for exynos5 and exynos4. Exynos5 hdmi driver
 is dt based while exynos4 hdmi driver is not.

 Signed-off-by: Rahul Sharma rahul.sha...@samsung.com
 Signed-off-by: Shirish S s.shir...@samsung.com
 Signed-off-by: Fahad Kunnathadi faha...@samsung.com
 ---
   drivers/gpu/drm/exynos/exynos_hdmi.c |  300
 ++
   1 files changed, 269 insertions(+), 31 deletions(-)

 diff --git a/drivers/gpu/drm/exynos/exynos_hdmi.c
 b/drivers/gpu/drm/exynos/exynos_hdmi.c
 index a6aea6f..5236256 100644
 --- a/drivers/gpu/drm/exynos/exynos_hdmi.c
 +++ b/drivers/gpu/drm/exynos/exynos_hdmi.c
 @@ -32,6 +32,9 @@
   #include linux/pm_runtime.h
   #include linux/clk.h
   #include linux/regulator/consumer.h
 +#include linux/io.h
 +#include linux/of_gpio.h
 +#include plat/gpio-cfg.h
 #include drm/exynos_drm.h
   @@ -61,11 +64,13 @@ struct hdmi_context {
 boolpowered;
 boolis_v13;
 booldvi_mode;
 +   boolis_soc_exynos5;
 struct mutexhdmi_mutex;
 void __iomem*regs;
 -   unsigned intexternal_irq;
 -   unsigned intinternal_irq;
 +   int external_irq;
 +   int internal_irq;
 +   int hpd_gpio;
 struct i2c_client   *ddc_port;
 struct i2c_client   *hdmiphy_port;
 @@ -953,6 +958,23 @@ static inline void hdmi_reg_writemask(struct
 hdmi_context *hdata,
 writel(value, hdata-regs + reg_id);
   }
   +static void hdmi_cfg_hpd(struct hdmi_context *hdata, bool internal)
 +{
 +   if (!internal) {
 +   s3c_gpio_cfgpin(hdata-hpd_gpio, S3C_GPIO_SFN(0xf));
 +   s3c_gpio_setpull(hdata-hpd_gpio, S3C_GPIO_PULL_DOWN);
 +   } else {
 +   s3c_gpio_cfgpin(hdata-hpd_gpio, S3C_GPIO_SFN(3));
 +   s3c_gpio_setpull(hdata-hpd_gpio, S3C_GPIO_PULL_NONE);
 +   }
 +}
 +


 Don't use SoC specific functions in the driver.


 +static int hdmi_get_hpd(struct hdmi_context *hdata)
 +{
 +   int gpio_stat = gpio_get_value(hdata-hpd_gpio);
 +   return gpio_stat;
 +}
 +


 Actually, above two functions should come from platform data, but these
 will remove soon.


I had no option to pass above function pointers through hdmi device tree node
in exynos5. I can still pass these pointers through plf data by searching the
DT node and initializing the platform data ptr in the Machine Init file 
(mach-ecynos5-dt.c)
which is again not recommended. 
I preferred this approach since many drivers LCD, eeprom, nand drivers 
configuring, getting
GPIO this way. One or the other way we have to go off-track.
Please give me your opinion.


   static void hdmi_v13_regs_dump(struct hdmi_context *hdata, char *prefix)
   {
   #define DUMPREG(reg_id) \
 @@ -2026,6 +2048,9 @@ static void hdmi_poweron(struct hdmi_context *hdata)
 if (hdata-cfg_hpd)
 hdata-cfg_hpd(true);
 +   else
 +   hdmi_cfg_hpd(hdata, true);
 +
 mutex_unlock(hdata-hdmi_mutex);
 pm_runtime_get_sync(hdata-dev);
 @@ -2063,6 +2088,8 @@ static void hdmi_poweroff(struct hdmi_context
 *hdata)
 mutex_lock(hdata-hdmi_mutex);
 if (hdata-cfg_hpd)
 hdata-cfg_hpd(false);
 +   else
 +   hdmi_cfg_hpd(hdata, false);
 hdata-powered = false;
   @@ -2110,17 +2137,16 @@ static irqreturn_t hdmi_external_irq_thread(int
 irq, void *arg)
 struct exynos_drm_hdmi_context *ctx = arg;
 struct hdmi_context *hdata = ctx-ctx;
   - if (!hdata-get_hpd)
 -   goto out;
 -
 mutex_lock(hdata-hdmi_mutex);
 -   hdata-hpd = hdata-get_hpd();
 +   if (hdata-get_hpd)
 +   hdata-hpd = hdata-get_hpd();
 +   else
 +   hdata-hpd = hdmi_get_hpd(hdata);
 mutex_unlock(hdata-hdmi_mutex);
 if (ctx-drm_dev)
 drm_helper_hpd_irq_event(ctx-drm_dev);
   -out:
 return IRQ_HANDLED;
   }
   @@ -2203,23 +2229,25 @@ static int __devinit hdmi_resources_init(struct
 hdmi_context *hdata)
 clk_set_parent(res-sclk_hdmi, res-sclk_pixel);
   - res-regul_bulk = kzalloc(ARRAY_SIZE(supply) *
 -   sizeof(res-regul_bulk[0]), GFP_KERNEL);
 -   if (!res-regul_bulk) {
 -   DRM_ERROR(failed to get memory for regulators\n);
 -   goto fail;
 -   }
 -   for (i = 0; i  ARRAY_SIZE(supply); ++i) {
 -   res-regul_bulk[i].supply = supply[i];
 -   res-regul_bulk[i].consumer = NULL;
 -   }
 -   ret = 

[PATCH 2/3] drm: exynos: hdmi: add exynos5 support to hdmi driver

2012-09-12 Thread Rahul Sharma
Added support for exynos5 to hdmi driver. Resource init
is splitted for exynos5 and exynos4. Exynos5 hdmi driver
is dt based while exynos4 hdmi driver is not.

Signed-off-by: Rahul Sharma 
Signed-off-by: Shirish S 
Signed-off-by: Fahad Kunnathadi 
---
 drivers/gpu/drm/exynos/exynos_hdmi.c |  300 ++
 1 files changed, 269 insertions(+), 31 deletions(-)

diff --git a/drivers/gpu/drm/exynos/exynos_hdmi.c 
b/drivers/gpu/drm/exynos/exynos_hdmi.c
index a6aea6f..5236256 100644
--- a/drivers/gpu/drm/exynos/exynos_hdmi.c
+++ b/drivers/gpu/drm/exynos/exynos_hdmi.c
@@ -32,6 +32,9 @@
 #include 
 #include 
 #include 
+#include 
+#include 
+#include 

 #include 

@@ -61,11 +64,13 @@ struct hdmi_context {
boolpowered;
boolis_v13;
booldvi_mode;
+   boolis_soc_exynos5;
struct mutexhdmi_mutex;

void __iomem*regs;
-   unsigned intexternal_irq;
-   unsigned intinternal_irq;
+   int external_irq;
+   int internal_irq;
+   int hpd_gpio;

struct i2c_client   *ddc_port;
struct i2c_client   *hdmiphy_port;
@@ -953,6 +958,23 @@ static inline void hdmi_reg_writemask(struct hdmi_context 
*hdata,
writel(value, hdata->regs + reg_id);
 }

+static void hdmi_cfg_hpd(struct hdmi_context *hdata, bool internal)
+{
+   if (!internal) {
+   s3c_gpio_cfgpin(hdata->hpd_gpio, S3C_GPIO_SFN(0xf));
+   s3c_gpio_setpull(hdata->hpd_gpio, S3C_GPIO_PULL_DOWN);
+   } else {
+   s3c_gpio_cfgpin(hdata->hpd_gpio, S3C_GPIO_SFN(3));
+   s3c_gpio_setpull(hdata->hpd_gpio, S3C_GPIO_PULL_NONE);
+   }
+}
+
+static int hdmi_get_hpd(struct hdmi_context *hdata)
+{
+   int gpio_stat = gpio_get_value(hdata->hpd_gpio);
+   return gpio_stat;
+}
+
 static void hdmi_v13_regs_dump(struct hdmi_context *hdata, char *prefix)
 {
 #define DUMPREG(reg_id) \
@@ -2026,6 +2048,9 @@ static void hdmi_poweron(struct hdmi_context *hdata)

if (hdata->cfg_hpd)
hdata->cfg_hpd(true);
+   else
+   hdmi_cfg_hpd(hdata, true);
+
mutex_unlock(>hdmi_mutex);

pm_runtime_get_sync(hdata->dev);
@@ -2063,6 +2088,8 @@ static void hdmi_poweroff(struct hdmi_context *hdata)
mutex_lock(>hdmi_mutex);
if (hdata->cfg_hpd)
hdata->cfg_hpd(false);
+   else
+   hdmi_cfg_hpd(hdata, false);

hdata->powered = false;

@@ -2110,17 +2137,16 @@ static irqreturn_t hdmi_external_irq_thread(int irq, 
void *arg)
struct exynos_drm_hdmi_context *ctx = arg;
struct hdmi_context *hdata = ctx->ctx;

-   if (!hdata->get_hpd)
-   goto out;
-
mutex_lock(>hdmi_mutex);
-   hdata->hpd = hdata->get_hpd();
+   if (hdata->get_hpd)
+   hdata->hpd = hdata->get_hpd();
+   else
+   hdata->hpd = hdmi_get_hpd(hdata);
mutex_unlock(>hdmi_mutex);

if (ctx->drm_dev)
drm_helper_hpd_irq_event(ctx->drm_dev);

-out:
return IRQ_HANDLED;
 }

@@ -2203,23 +2229,25 @@ static int __devinit hdmi_resources_init(struct 
hdmi_context *hdata)

clk_set_parent(res->sclk_hdmi, res->sclk_pixel);

-   res->regul_bulk = kzalloc(ARRAY_SIZE(supply) *
-   sizeof(res->regul_bulk[0]), GFP_KERNEL);
-   if (!res->regul_bulk) {
-   DRM_ERROR("failed to get memory for regulators\n");
-   goto fail;
-   }
-   for (i = 0; i < ARRAY_SIZE(supply); ++i) {
-   res->regul_bulk[i].supply = supply[i];
-   res->regul_bulk[i].consumer = NULL;
-   }
-   ret = regulator_bulk_get(dev, ARRAY_SIZE(supply), res->regul_bulk);
-   if (ret) {
-   DRM_ERROR("failed to get regulators\n");
-   goto fail;
+   if (!hdata->is_soc_exynos5) {
+   res->regul_bulk = kzalloc(ARRAY_SIZE(supply) *
+   sizeof(res->regul_bulk[0]), GFP_KERNEL);
+   if (!res->regul_bulk) {
+   DRM_ERROR("failed to get memory for regulators\n");
+   goto fail;
+   }
+   for (i = 0; i < ARRAY_SIZE(supply); ++i) {
+   res->regul_bulk[i].supply = supply[i];
+   res->regul_bulk[i].consumer = NULL;
+   }
+   ret = regulator_bulk_get(dev, ARRAY_SIZE(supply),
+   res->regul_bulk);
+   if (ret) {
+   DRM_ERROR("failed to get regulators\n");
+   goto fail;
+   }
+   res->regul_count = ARRAY_SIZE(supply);

[PATCH 2/3] drm: exynos: hdmi: add exynos5 support to hdmi driver

2012-09-12 Thread Rahul Sharma
Added support for exynos5 to hdmi driver. Resource init
is splitted for exynos5 and exynos4. Exynos5 hdmi driver
is dt based while exynos4 hdmi driver is not.

Signed-off-by: Rahul Sharma rahul.sha...@samsung.com
Signed-off-by: Shirish S s.shir...@samsung.com
Signed-off-by: Fahad Kunnathadi faha...@samsung.com
---
 drivers/gpu/drm/exynos/exynos_hdmi.c |  300 ++
 1 files changed, 269 insertions(+), 31 deletions(-)

diff --git a/drivers/gpu/drm/exynos/exynos_hdmi.c 
b/drivers/gpu/drm/exynos/exynos_hdmi.c
index a6aea6f..5236256 100644
--- a/drivers/gpu/drm/exynos/exynos_hdmi.c
+++ b/drivers/gpu/drm/exynos/exynos_hdmi.c
@@ -32,6 +32,9 @@
 #include linux/pm_runtime.h
 #include linux/clk.h
 #include linux/regulator/consumer.h
+#include linux/io.h
+#include linux/of_gpio.h
+#include plat/gpio-cfg.h
 
 #include drm/exynos_drm.h
 
@@ -61,11 +64,13 @@ struct hdmi_context {
boolpowered;
boolis_v13;
booldvi_mode;
+   boolis_soc_exynos5;
struct mutexhdmi_mutex;
 
void __iomem*regs;
-   unsigned intexternal_irq;
-   unsigned intinternal_irq;
+   int external_irq;
+   int internal_irq;
+   int hpd_gpio;
 
struct i2c_client   *ddc_port;
struct i2c_client   *hdmiphy_port;
@@ -953,6 +958,23 @@ static inline void hdmi_reg_writemask(struct hdmi_context 
*hdata,
writel(value, hdata-regs + reg_id);
 }
 
+static void hdmi_cfg_hpd(struct hdmi_context *hdata, bool internal)
+{
+   if (!internal) {
+   s3c_gpio_cfgpin(hdata-hpd_gpio, S3C_GPIO_SFN(0xf));
+   s3c_gpio_setpull(hdata-hpd_gpio, S3C_GPIO_PULL_DOWN);
+   } else {
+   s3c_gpio_cfgpin(hdata-hpd_gpio, S3C_GPIO_SFN(3));
+   s3c_gpio_setpull(hdata-hpd_gpio, S3C_GPIO_PULL_NONE);
+   }
+}
+
+static int hdmi_get_hpd(struct hdmi_context *hdata)
+{
+   int gpio_stat = gpio_get_value(hdata-hpd_gpio);
+   return gpio_stat;
+}
+
 static void hdmi_v13_regs_dump(struct hdmi_context *hdata, char *prefix)
 {
 #define DUMPREG(reg_id) \
@@ -2026,6 +2048,9 @@ static void hdmi_poweron(struct hdmi_context *hdata)
 
if (hdata-cfg_hpd)
hdata-cfg_hpd(true);
+   else
+   hdmi_cfg_hpd(hdata, true);
+
mutex_unlock(hdata-hdmi_mutex);
 
pm_runtime_get_sync(hdata-dev);
@@ -2063,6 +2088,8 @@ static void hdmi_poweroff(struct hdmi_context *hdata)
mutex_lock(hdata-hdmi_mutex);
if (hdata-cfg_hpd)
hdata-cfg_hpd(false);
+   else
+   hdmi_cfg_hpd(hdata, false);
 
hdata-powered = false;
 
@@ -2110,17 +2137,16 @@ static irqreturn_t hdmi_external_irq_thread(int irq, 
void *arg)
struct exynos_drm_hdmi_context *ctx = arg;
struct hdmi_context *hdata = ctx-ctx;
 
-   if (!hdata-get_hpd)
-   goto out;
-
mutex_lock(hdata-hdmi_mutex);
-   hdata-hpd = hdata-get_hpd();
+   if (hdata-get_hpd)
+   hdata-hpd = hdata-get_hpd();
+   else
+   hdata-hpd = hdmi_get_hpd(hdata);
mutex_unlock(hdata-hdmi_mutex);
 
if (ctx-drm_dev)
drm_helper_hpd_irq_event(ctx-drm_dev);
 
-out:
return IRQ_HANDLED;
 }
 
@@ -2203,23 +2229,25 @@ static int __devinit hdmi_resources_init(struct 
hdmi_context *hdata)
 
clk_set_parent(res-sclk_hdmi, res-sclk_pixel);
 
-   res-regul_bulk = kzalloc(ARRAY_SIZE(supply) *
-   sizeof(res-regul_bulk[0]), GFP_KERNEL);
-   if (!res-regul_bulk) {
-   DRM_ERROR(failed to get memory for regulators\n);
-   goto fail;
-   }
-   for (i = 0; i  ARRAY_SIZE(supply); ++i) {
-   res-regul_bulk[i].supply = supply[i];
-   res-regul_bulk[i].consumer = NULL;
-   }
-   ret = regulator_bulk_get(dev, ARRAY_SIZE(supply), res-regul_bulk);
-   if (ret) {
-   DRM_ERROR(failed to get regulators\n);
-   goto fail;
+   if (!hdata-is_soc_exynos5) {
+   res-regul_bulk = kzalloc(ARRAY_SIZE(supply) *
+   sizeof(res-regul_bulk[0]), GFP_KERNEL);
+   if (!res-regul_bulk) {
+   DRM_ERROR(failed to get memory for regulators\n);
+   goto fail;
+   }
+   for (i = 0; i  ARRAY_SIZE(supply); ++i) {
+   res-regul_bulk[i].supply = supply[i];
+   res-regul_bulk[i].consumer = NULL;
+   }
+   ret = regulator_bulk_get(dev, ARRAY_SIZE(supply),
+   res-regul_bulk);
+   if (ret) {
+   

Re: [PATCH 2/3] drm: exynos: hdmi: add exynos5 support to hdmi driver

2012-09-12 Thread Joonyoung Shim

Hi, Rahul.

Overall, i think this patch causes messy codes.

On 09/12/2012 09:08 PM, Rahul Sharma wrote:

Added support for exynos5 to hdmi driver. Resource init
is splitted for exynos5 and exynos4. Exynos5 hdmi driver
is dt based while exynos4 hdmi driver is not.

Signed-off-by: Rahul Sharma rahul.sha...@samsung.com
Signed-off-by: Shirish S s.shir...@samsung.com
Signed-off-by: Fahad Kunnathadi faha...@samsung.com
---
  drivers/gpu/drm/exynos/exynos_hdmi.c |  300 ++
  1 files changed, 269 insertions(+), 31 deletions(-)

diff --git a/drivers/gpu/drm/exynos/exynos_hdmi.c 
b/drivers/gpu/drm/exynos/exynos_hdmi.c
index a6aea6f..5236256 100644
--- a/drivers/gpu/drm/exynos/exynos_hdmi.c
+++ b/drivers/gpu/drm/exynos/exynos_hdmi.c
@@ -32,6 +32,9 @@
  #include linux/pm_runtime.h
  #include linux/clk.h
  #include linux/regulator/consumer.h
+#include linux/io.h
+#include linux/of_gpio.h
+#include plat/gpio-cfg.h
  
  #include drm/exynos_drm.h
  
@@ -61,11 +64,13 @@ struct hdmi_context {

boolpowered;
boolis_v13;
booldvi_mode;
+   boolis_soc_exynos5;
struct mutexhdmi_mutex;
  
  	void __iomem			*regs;

-   unsigned intexternal_irq;
-   unsigned intinternal_irq;
+   int external_irq;
+   int internal_irq;
+   int hpd_gpio;
  
  	struct i2c_client		*ddc_port;

struct i2c_client   *hdmiphy_port;
@@ -953,6 +958,23 @@ static inline void hdmi_reg_writemask(struct hdmi_context 
*hdata,
writel(value, hdata-regs + reg_id);
  }
  
+static void hdmi_cfg_hpd(struct hdmi_context *hdata, bool internal)

+{
+   if (!internal) {
+   s3c_gpio_cfgpin(hdata-hpd_gpio, S3C_GPIO_SFN(0xf));
+   s3c_gpio_setpull(hdata-hpd_gpio, S3C_GPIO_PULL_DOWN);
+   } else {
+   s3c_gpio_cfgpin(hdata-hpd_gpio, S3C_GPIO_SFN(3));
+   s3c_gpio_setpull(hdata-hpd_gpio, S3C_GPIO_PULL_NONE);
+   }
+}
+


Don't use SoC specific functions in the driver.


+static int hdmi_get_hpd(struct hdmi_context *hdata)
+{
+   int gpio_stat = gpio_get_value(hdata-hpd_gpio);
+   return gpio_stat;
+}
+


Actually, above two functions should come from platform data, but these
will remove soon.


  static void hdmi_v13_regs_dump(struct hdmi_context *hdata, char *prefix)
  {
  #define DUMPREG(reg_id) \
@@ -2026,6 +2048,9 @@ static void hdmi_poweron(struct hdmi_context *hdata)
  
  	if (hdata-cfg_hpd)

hdata-cfg_hpd(true);
+   else
+   hdmi_cfg_hpd(hdata, true);
+
mutex_unlock(hdata-hdmi_mutex);
  
  	pm_runtime_get_sync(hdata-dev);

@@ -2063,6 +2088,8 @@ static void hdmi_poweroff(struct hdmi_context *hdata)
mutex_lock(hdata-hdmi_mutex);
if (hdata-cfg_hpd)
hdata-cfg_hpd(false);
+   else
+   hdmi_cfg_hpd(hdata, false);
  
  	hdata-powered = false;
  
@@ -2110,17 +2137,16 @@ static irqreturn_t hdmi_external_irq_thread(int irq, void *arg)

struct exynos_drm_hdmi_context *ctx = arg;
struct hdmi_context *hdata = ctx-ctx;
  
-	if (!hdata-get_hpd)

-   goto out;
-
mutex_lock(hdata-hdmi_mutex);
-   hdata-hpd = hdata-get_hpd();
+   if (hdata-get_hpd)
+   hdata-hpd = hdata-get_hpd();
+   else
+   hdata-hpd = hdmi_get_hpd(hdata);
mutex_unlock(hdata-hdmi_mutex);
  
  	if (ctx-drm_dev)

drm_helper_hpd_irq_event(ctx-drm_dev);
  
-out:

return IRQ_HANDLED;
  }
  
@@ -2203,23 +2229,25 @@ static int __devinit hdmi_resources_init(struct hdmi_context *hdata)
  
  	clk_set_parent(res-sclk_hdmi, res-sclk_pixel);
  
-	res-regul_bulk = kzalloc(ARRAY_SIZE(supply) *

-   sizeof(res-regul_bulk[0]), GFP_KERNEL);
-   if (!res-regul_bulk) {
-   DRM_ERROR(failed to get memory for regulators\n);
-   goto fail;
-   }
-   for (i = 0; i  ARRAY_SIZE(supply); ++i) {
-   res-regul_bulk[i].supply = supply[i];
-   res-regul_bulk[i].consumer = NULL;
-   }
-   ret = regulator_bulk_get(dev, ARRAY_SIZE(supply), res-regul_bulk);
-   if (ret) {
-   DRM_ERROR(failed to get regulators\n);
-   goto fail;
+   if (!hdata-is_soc_exynos5) {
+   res-regul_bulk = kzalloc(ARRAY_SIZE(supply) *
+   sizeof(res-regul_bulk[0]), GFP_KERNEL);
+   if (!res-regul_bulk) {
+   DRM_ERROR(failed to get memory for regulators\n);
+   goto fail;
+   }
+   for (i = 0; i  ARRAY_SIZE(supply); ++i) {
+   res-regul_bulk[i].supply = supply[i];
+