Re: [PATCH 1/2] mailbox: samsung: added support for samsung mailbox

2014-03-18 Thread Girish KS
On Tue, Mar 18, 2014 at 4:26 PM, Joe Perches  wrote:
> On Tue, 2014-03-18 at 15:52 +0530, Girish KS wrote:
>> On Mon, Mar 17, 2014 at 5:33 PM, Girish K S  wrote:
>
> Hi, just some trivial notes about the patch
>
>> > diff --git a/drivers/mailbox/mailbox-samsung.c 
>> > b/drivers/mailbox/mailbox-samsung.c
> []
>> > @@ -0,0 +1,354 @@
>> > +/*
>> > + * Copyright 2013 Samsung Electronics Co. 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 .
>> > + */
>
> Please add
>
> #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
>
> before any #include so that error messages are
> prefixed in the output with "samsung-mailbox: "
> and the reader of the log has an idea what subsystem
> is emitting messages.
>
Sure will do it

>> > +#include 
>> > +#include 
>> > +#include 
> []
>> > +static int samsung_mbox_send_data(struct ipc_link *link, void *msg)
>> > +{
> []
>> > +   /* Lock the mailbox for this transaction with the client id */
>> > +   writel(val, ipc_base + MBOX_REG_TXLOCK);
>> > +   do {
>> > +   if (time_after(jiffies, timeout)) {
>> > +   pr_err("cannot aquire the lock\n");
>
> This would be prefixed appropriately via pr_fmt.
> Also, there's a typo of aquire here: acquire

OK

>
>> > +static int samsung_mbox_startup(struct ipc_link *link, void *ignored)
>> > +{
> []
>> > +   ret = devm_request_irq(dev, samsung_link->irq, samsung_ipc_handler,
>> > +   IRQF_SHARED, link->link_name,
>> > +   samsung_link);
>> > +   if (unlikely(ret)) {
>> > +   pr_err("failed to register mailbox interrupt:%d\n", ret);
>
> Here too it would be prefixed

ok

>
>> > +static int samsung_mbox_probe(struct platform_device *pdev)
>> > +{
>> > +   struct samsung_mbox *samsung_mbox;
>> > +   struct samsung_mlink *mbox_link;
>> > +   struct resource res;
>> > +   struct ipc_link **link;
>> > +   int loop, count, ret = 0;
>> > +   struct device_node *node = pdev->dev.of_node;
>> > +
>> > +   if (!node) {
>> > +   dev_err(>dev, "driver doesnt support"
>> > +   "non-dt devices\n");
>
> Please coalesce the format fragments.
>
> You would notice the missing space between
> "support" and "non-dt"

ok

>
> dev_err(>dev, "driver does not support non-dt 
> devices\n");
>
> It's OK to exceed 80 columns for these format strings.
>
>> > diff --git a/include/linux/mailbox-samsung.h 
>> > b/include/linux/mailbox-samsung.h
> []
>> > +static inline unsigned long get_alligned_buffer(void)
>
> Typo: There's one l in aligned

will do it

>
>> > +{
>> > +   return __get_free_pages(GFP_KERNEL, REQUEST_PAGE_ORDER);
>> > +}
>> > +
>> > +static inline void put_alligned_buffer(unsigned long addr)
>> > +{
>
> here too
>
>> > +   free_pages(addr, REQUEST_PAGE_ORDER);
>> > +}
>> > +
>
>
--
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] mailbox: samsung: added support for samsung mailbox

2014-03-18 Thread Joe Perches
On Tue, 2014-03-18 at 15:52 +0530, Girish KS wrote:
> On Mon, Mar 17, 2014 at 5:33 PM, Girish K S  wrote:

Hi, just some trivial notes about the patch

> > diff --git a/drivers/mailbox/mailbox-samsung.c 
> > b/drivers/mailbox/mailbox-samsung.c
[]
> > @@ -0,0 +1,354 @@
> > +/*
> > + * Copyright 2013 Samsung Electronics Co. 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 .
> > + */

Please add

#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt

before any #include so that error messages are
prefixed in the output with "samsung-mailbox: "
and the reader of the log has an idea what subsystem
is emitting messages.

> > +#include 
> > +#include 
> > +#include 
[]
> > +static int samsung_mbox_send_data(struct ipc_link *link, void *msg)
> > +{
[]
> > +   /* Lock the mailbox for this transaction with the client id */
> > +   writel(val, ipc_base + MBOX_REG_TXLOCK);
> > +   do {
> > +   if (time_after(jiffies, timeout)) {
> > +   pr_err("cannot aquire the lock\n");

This would be prefixed appropriately via pr_fmt.
Also, there's a typo of aquire here: acquire

> > +static int samsung_mbox_startup(struct ipc_link *link, void *ignored)
> > +{
[]
> > +   ret = devm_request_irq(dev, samsung_link->irq, samsung_ipc_handler,
> > +   IRQF_SHARED, link->link_name,
> > +   samsung_link);
> > +   if (unlikely(ret)) {
> > +   pr_err("failed to register mailbox interrupt:%d\n", ret);

Here too it would be prefixed

> > +static int samsung_mbox_probe(struct platform_device *pdev)
> > +{
> > +   struct samsung_mbox *samsung_mbox;
> > +   struct samsung_mlink *mbox_link;
> > +   struct resource res;
> > +   struct ipc_link **link;
> > +   int loop, count, ret = 0;
> > +   struct device_node *node = pdev->dev.of_node;
> > +
> > +   if (!node) {
> > +   dev_err(>dev, "driver doesnt support"
> > +   "non-dt devices\n");

Please coalesce the format fragments.

You would notice the missing space between
"support" and "non-dt"

dev_err(>dev, "driver does not support non-dt devices\n");

It's OK to exceed 80 columns for these format strings.

> > diff --git a/include/linux/mailbox-samsung.h 
> > b/include/linux/mailbox-samsung.h
[]
> > +static inline unsigned long get_alligned_buffer(void)

Typo: There's one l in aligned

> > +{
> > +   return __get_free_pages(GFP_KERNEL, REQUEST_PAGE_ORDER);
> > +}
> > +
> > +static inline void put_alligned_buffer(unsigned long addr)
> > +{

here too

> > +   free_pages(addr, REQUEST_PAGE_ORDER);
> > +}
> > +


--
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] mailbox: samsung: added support for samsung mailbox

2014-03-18 Thread Girish KS
On Mon, Mar 17, 2014 at 5:33 PM, Girish K S  wrote:
> This patch adds support to the samsung mailbox driver.
>
> Signed-off-by: Girish K S 
> ---
>  drivers/mailbox/Kconfig   |8 +
>  drivers/mailbox/Makefile  |2 +
>  drivers/mailbox/mailbox-samsung.c |  354 
> +
>  include/linux/mailbox-samsung.h   |  112 
>  4 files changed, 476 insertions(+)
>  create mode 100644 drivers/mailbox/mailbox-samsung.c
>  create mode 100644 include/linux/mailbox-samsung.h
>
> diff --git a/drivers/mailbox/Kconfig b/drivers/mailbox/Kconfig
> index c8b5c13..bce60ba 100644
> --- a/drivers/mailbox/Kconfig
> +++ b/drivers/mailbox/Kconfig
> @@ -23,6 +23,14 @@ config OMAP_MBOX
>   driver such as CONFIG_OMAP1_MBOX or CONFIG_OMAP2PLUS_MBOX. This
>   enables the common OMAP mailbox framework code.
>
> +config SAMSUNG_MBOX
> +   tristate "Samsung Mailbox Controller"
> +   help
> + An implementation of the Samsung Interprocessor Communication
> + Mailbox (IPCM). It is used to send short messages between A57 cores
> + and the System Control Processor or Network Coprocessor firmware.
> + Say Y here if you want to use the Samsung IPCM support.
> +
>  config OMAP1_MBOX
> tristate "OMAP1 Mailbox framework support"
> depends on ARCH_OMAP1
> diff --git a/drivers/mailbox/Makefile b/drivers/mailbox/Makefile
> index 2fa343a..7e83a7d 100644
> --- a/drivers/mailbox/Makefile
> +++ b/drivers/mailbox/Makefile
> @@ -9,3 +9,5 @@ obj-$(CONFIG_OMAP1_MBOX)+= mailbox_omap1.o
>  mailbox_omap1-objs := mailbox-omap1.o
>  obj-$(CONFIG_OMAP2PLUS_MBOX)   += mailbox_omap2.o
>  mailbox_omap2-objs := mailbox-omap2.o
> +obj-$(CONFIG_SAMSUNG_MBOX) += mailbox_samsung.o
> +mailbox_samsung-objs   := mailbox-samsung.o
> diff --git a/drivers/mailbox/mailbox-samsung.c 
> b/drivers/mailbox/mailbox-samsung.c
> new file mode 100644
> index 000..903e88a
> --- /dev/null
> +++ b/drivers/mailbox/mailbox-samsung.c
> @@ -0,0 +1,354 @@
> +/*
> + * Copyright 2013 Samsung Electronics Co. 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 .
> + */
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +
> +/*
> +   Mailbox Register offsets
> + */
> +
> +/* Offset of tx mailbox data registers */
> +#define MBOX_REG_RXDATA0   0
> +#define MBOX_REG_RXDATA1   4
> +
> +/* offset of tx mailbox lock registers */
> +#define MBOX_REG_RXLOCK8
> +#define MBOX_REG_RXUNLOCK  12
> +
> +/* offset of tx mailbox interrupt registers */
> +#define MBOX_REG_RXINT 16
> +
> +/* Offset of rx mailbox data registers */
> +#define MBOX_REG_TXDATA0   32
> +#define MBOX_REG_TXDATA1   36
> +
> +/* offset of rx mailbox lock registers */
> +#define MBOX_REG_TXLOCK40
> +#define MBOX_REG_TXUNLOCK  44
> +
> +/* offset of rx mailbox interrupt registers */
> +#define MBOX_REG_TXINT 48
> +
> +#define MBOX_RX_TX_FULL1
> +#define MBOX_INT_ENABLE1
> +
> +#define MBOX_LOCK_RESET(-1)
> +#define MBOX_WAIT_TIMEOUT  (1)
> +
> +#define RXBUF_LEN  32
> +#define MAX_LINKS  1
> +
> +struct samsung_mlink {
> +   const char *name;
> +   struct ipc_link link;
> +   struct samsung_mbox *smc;
> +   int irq;
> +   void *data;
> +};
> +
> +struct samsung_mbox {
> +   struct device *dev;
> +   void __iomem *ipc_base;
> +   struct ipc_controller ipc_con;
> +   struct mutex lock;
> +   struct samsung_mlink samsung_link[MAX_LINKS];
> +};
> +
> +static inline struct samsung_mlink *to_samsung_mlink(struct ipc_link *plink)
> +{
> +   if (!plink)
> +   return NULL;
> +
> +   return container_of(plink, struct samsung_mlink, link);
> +}
> +
> +static inline struct samsung_mbox *to_samsung_mbox(struct ipc_link *plink)
> +{
> +   if (!plink)
> +   return NULL;
> +
> +   return to_samsung_mlink(plink)->smc;
> +}
> +
> +static void samsung_mbox_read(struct samsung_mlink *link)
> +{
> +   u64 data;
> +   void __iomem *ipc_base = link->smc->ipc_base;
> +
> +   /* Read both words which have information specific to client */
> +   data = readq(ipc_base + 

Re: [PATCH 1/2] mailbox: samsung: added support for samsung mailbox

2014-03-18 Thread Girish KS
On Mon, Mar 17, 2014 at 5:33 PM, Girish K S ks.g...@samsung.com wrote:
 This patch adds support to the samsung mailbox driver.

 Signed-off-by: Girish K S ks.g...@samsung.com
 ---
  drivers/mailbox/Kconfig   |8 +
  drivers/mailbox/Makefile  |2 +
  drivers/mailbox/mailbox-samsung.c |  354 
 +
  include/linux/mailbox-samsung.h   |  112 
  4 files changed, 476 insertions(+)
  create mode 100644 drivers/mailbox/mailbox-samsung.c
  create mode 100644 include/linux/mailbox-samsung.h

 diff --git a/drivers/mailbox/Kconfig b/drivers/mailbox/Kconfig
 index c8b5c13..bce60ba 100644
 --- a/drivers/mailbox/Kconfig
 +++ b/drivers/mailbox/Kconfig
 @@ -23,6 +23,14 @@ config OMAP_MBOX
   driver such as CONFIG_OMAP1_MBOX or CONFIG_OMAP2PLUS_MBOX. This
   enables the common OMAP mailbox framework code.

 +config SAMSUNG_MBOX
 +   tristate Samsung Mailbox Controller
 +   help
 + An implementation of the Samsung Interprocessor Communication
 + Mailbox (IPCM). It is used to send short messages between A57 cores
 + and the System Control Processor or Network Coprocessor firmware.
 + Say Y here if you want to use the Samsung IPCM support.
 +
  config OMAP1_MBOX
 tristate OMAP1 Mailbox framework support
 depends on ARCH_OMAP1
 diff --git a/drivers/mailbox/Makefile b/drivers/mailbox/Makefile
 index 2fa343a..7e83a7d 100644
 --- a/drivers/mailbox/Makefile
 +++ b/drivers/mailbox/Makefile
 @@ -9,3 +9,5 @@ obj-$(CONFIG_OMAP1_MBOX)+= mailbox_omap1.o
  mailbox_omap1-objs := mailbox-omap1.o
  obj-$(CONFIG_OMAP2PLUS_MBOX)   += mailbox_omap2.o
  mailbox_omap2-objs := mailbox-omap2.o
 +obj-$(CONFIG_SAMSUNG_MBOX) += mailbox_samsung.o
 +mailbox_samsung-objs   := mailbox-samsung.o
 diff --git a/drivers/mailbox/mailbox-samsung.c 
 b/drivers/mailbox/mailbox-samsung.c
 new file mode 100644
 index 000..903e88a
 --- /dev/null
 +++ b/drivers/mailbox/mailbox-samsung.c
 @@ -0,0 +1,354 @@
 +/*
 + * Copyright 2013 Samsung Electronics Co. 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/err.h
 +#include linux/module.h
 +#include linux/slab.h
 +#include linux/interrupt.h
 +#include linux/io.h
 +#include linux/jiffies.h
 +#include linux/mailbox_controller.h
 +#include linux/mailbox-samsung.h
 +#include linux/mutex.h
 +#include linux/of.h
 +#include linux/of_address.h
 +#include linux/of_irq.h
 +#include linux/platform_device.h
 +
 +/*
 +   Mailbox Register offsets
 + */
 +
 +/* Offset of tx mailbox data registers */
 +#define MBOX_REG_RXDATA0   0
 +#define MBOX_REG_RXDATA1   4
 +
 +/* offset of tx mailbox lock registers */
 +#define MBOX_REG_RXLOCK8
 +#define MBOX_REG_RXUNLOCK  12
 +
 +/* offset of tx mailbox interrupt registers */
 +#define MBOX_REG_RXINT 16
 +
 +/* Offset of rx mailbox data registers */
 +#define MBOX_REG_TXDATA0   32
 +#define MBOX_REG_TXDATA1   36
 +
 +/* offset of rx mailbox lock registers */
 +#define MBOX_REG_TXLOCK40
 +#define MBOX_REG_TXUNLOCK  44
 +
 +/* offset of rx mailbox interrupt registers */
 +#define MBOX_REG_TXINT 48
 +
 +#define MBOX_RX_TX_FULL1
 +#define MBOX_INT_ENABLE1
 +
 +#define MBOX_LOCK_RESET(-1)
 +#define MBOX_WAIT_TIMEOUT  (1)
 +
 +#define RXBUF_LEN  32
 +#define MAX_LINKS  1
 +
 +struct samsung_mlink {
 +   const char *name;
 +   struct ipc_link link;
 +   struct samsung_mbox *smc;
 +   int irq;
 +   void *data;
 +};
 +
 +struct samsung_mbox {
 +   struct device *dev;
 +   void __iomem *ipc_base;
 +   struct ipc_controller ipc_con;
 +   struct mutex lock;
 +   struct samsung_mlink samsung_link[MAX_LINKS];
 +};
 +
 +static inline struct samsung_mlink *to_samsung_mlink(struct ipc_link *plink)
 +{
 +   if (!plink)
 +   return NULL;
 +
 +   return container_of(plink, struct samsung_mlink, link);
 +}
 +
 +static inline struct samsung_mbox *to_samsung_mbox(struct ipc_link *plink)
 +{
 +   if (!plink)
 +   return NULL;
 +
 +   return to_samsung_mlink(plink)-smc;
 +}
 +
 +static void samsung_mbox_read(struct samsung_mlink *link)
 +{
 +   u64 data;
 +   void __iomem *ipc_base = link-smc-ipc_base;
 +
 +   /* Read both words 

Re: [PATCH 1/2] mailbox: samsung: added support for samsung mailbox

2014-03-18 Thread Joe Perches
On Tue, 2014-03-18 at 15:52 +0530, Girish KS wrote:
 On Mon, Mar 17, 2014 at 5:33 PM, Girish K S ks.g...@samsung.com wrote:

Hi, just some trivial notes about the patch

  diff --git a/drivers/mailbox/mailbox-samsung.c 
  b/drivers/mailbox/mailbox-samsung.c
[]
  @@ -0,0 +1,354 @@
  +/*
  + * Copyright 2013 Samsung Electronics Co. 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/.
  + */

Please add

#define pr_fmt(fmt) KBUILD_MODNAME :  fmt

before any #include so that error messages are
prefixed in the output with samsung-mailbox: 
and the reader of the log has an idea what subsystem
is emitting messages.

  +#include linux/err.h
  +#include linux/module.h
  +#include linux/slab.h
[]
  +static int samsung_mbox_send_data(struct ipc_link *link, void *msg)
  +{
[]
  +   /* Lock the mailbox for this transaction with the client id */
  +   writel(val, ipc_base + MBOX_REG_TXLOCK);
  +   do {
  +   if (time_after(jiffies, timeout)) {
  +   pr_err(cannot aquire the lock\n);

This would be prefixed appropriately via pr_fmt.
Also, there's a typo of aquire here: acquire

  +static int samsung_mbox_startup(struct ipc_link *link, void *ignored)
  +{
[]
  +   ret = devm_request_irq(dev, samsung_link-irq, samsung_ipc_handler,
  +   IRQF_SHARED, link-link_name,
  +   samsung_link);
  +   if (unlikely(ret)) {
  +   pr_err(failed to register mailbox interrupt:%d\n, ret);

Here too it would be prefixed

  +static int samsung_mbox_probe(struct platform_device *pdev)
  +{
  +   struct samsung_mbox *samsung_mbox;
  +   struct samsung_mlink *mbox_link;
  +   struct resource res;
  +   struct ipc_link **link;
  +   int loop, count, ret = 0;
  +   struct device_node *node = pdev-dev.of_node;
  +
  +   if (!node) {
  +   dev_err(pdev-dev, driver doesnt support
  +   non-dt devices\n);

Please coalesce the format fragments.

You would notice the missing space between
support and non-dt

dev_err(pdev-dev, driver does not support non-dt devices\n);

It's OK to exceed 80 columns for these format strings.

  diff --git a/include/linux/mailbox-samsung.h 
  b/include/linux/mailbox-samsung.h
[]
  +static inline unsigned long get_alligned_buffer(void)

Typo: There's one l in aligned

  +{
  +   return __get_free_pages(GFP_KERNEL, REQUEST_PAGE_ORDER);
  +}
  +
  +static inline void put_alligned_buffer(unsigned long addr)
  +{

here too

  +   free_pages(addr, REQUEST_PAGE_ORDER);
  +}
  +


--
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] mailbox: samsung: added support for samsung mailbox

2014-03-18 Thread Girish KS
On Tue, Mar 18, 2014 at 4:26 PM, Joe Perches j...@perches.com wrote:
 On Tue, 2014-03-18 at 15:52 +0530, Girish KS wrote:
 On Mon, Mar 17, 2014 at 5:33 PM, Girish K S ks.g...@samsung.com wrote:

 Hi, just some trivial notes about the patch

  diff --git a/drivers/mailbox/mailbox-samsung.c 
  b/drivers/mailbox/mailbox-samsung.c
 []
  @@ -0,0 +1,354 @@
  +/*
  + * Copyright 2013 Samsung Electronics Co. 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/.
  + */

 Please add

 #define pr_fmt(fmt) KBUILD_MODNAME :  fmt

 before any #include so that error messages are
 prefixed in the output with samsung-mailbox: 
 and the reader of the log has an idea what subsystem
 is emitting messages.

Sure will do it

  +#include linux/err.h
  +#include linux/module.h
  +#include linux/slab.h
 []
  +static int samsung_mbox_send_data(struct ipc_link *link, void *msg)
  +{
 []
  +   /* Lock the mailbox for this transaction with the client id */
  +   writel(val, ipc_base + MBOX_REG_TXLOCK);
  +   do {
  +   if (time_after(jiffies, timeout)) {
  +   pr_err(cannot aquire the lock\n);

 This would be prefixed appropriately via pr_fmt.
 Also, there's a typo of aquire here: acquire

OK


  +static int samsung_mbox_startup(struct ipc_link *link, void *ignored)
  +{
 []
  +   ret = devm_request_irq(dev, samsung_link-irq, samsung_ipc_handler,
  +   IRQF_SHARED, link-link_name,
  +   samsung_link);
  +   if (unlikely(ret)) {
  +   pr_err(failed to register mailbox interrupt:%d\n, ret);

 Here too it would be prefixed

ok


  +static int samsung_mbox_probe(struct platform_device *pdev)
  +{
  +   struct samsung_mbox *samsung_mbox;
  +   struct samsung_mlink *mbox_link;
  +   struct resource res;
  +   struct ipc_link **link;
  +   int loop, count, ret = 0;
  +   struct device_node *node = pdev-dev.of_node;
  +
  +   if (!node) {
  +   dev_err(pdev-dev, driver doesnt support
  +   non-dt devices\n);

 Please coalesce the format fragments.

 You would notice the missing space between
 support and non-dt

ok


 dev_err(pdev-dev, driver does not support non-dt 
 devices\n);

 It's OK to exceed 80 columns for these format strings.

  diff --git a/include/linux/mailbox-samsung.h 
  b/include/linux/mailbox-samsung.h
 []
  +static inline unsigned long get_alligned_buffer(void)

 Typo: There's one l in aligned

will do it


  +{
  +   return __get_free_pages(GFP_KERNEL, REQUEST_PAGE_ORDER);
  +}
  +
  +static inline void put_alligned_buffer(unsigned long addr)
  +{

 here too

  +   free_pages(addr, REQUEST_PAGE_ORDER);
  +}
  +


--
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] mailbox: samsung: added support for samsung mailbox

2014-03-17 Thread Girish K S
This patch adds support to the samsung mailbox driver.

Signed-off-by: Girish K S 
---
 drivers/mailbox/Kconfig   |8 +
 drivers/mailbox/Makefile  |2 +
 drivers/mailbox/mailbox-samsung.c |  354 +
 include/linux/mailbox-samsung.h   |  112 
 4 files changed, 476 insertions(+)
 create mode 100644 drivers/mailbox/mailbox-samsung.c
 create mode 100644 include/linux/mailbox-samsung.h

diff --git a/drivers/mailbox/Kconfig b/drivers/mailbox/Kconfig
index c8b5c13..bce60ba 100644
--- a/drivers/mailbox/Kconfig
+++ b/drivers/mailbox/Kconfig
@@ -23,6 +23,14 @@ config OMAP_MBOX
  driver such as CONFIG_OMAP1_MBOX or CONFIG_OMAP2PLUS_MBOX. This
  enables the common OMAP mailbox framework code.
 
+config SAMSUNG_MBOX
+   tristate "Samsung Mailbox Controller"
+   help
+ An implementation of the Samsung Interprocessor Communication
+ Mailbox (IPCM). It is used to send short messages between A57 cores
+ and the System Control Processor or Network Coprocessor firmware.
+ Say Y here if you want to use the Samsung IPCM support.
+
 config OMAP1_MBOX
tristate "OMAP1 Mailbox framework support"
depends on ARCH_OMAP1
diff --git a/drivers/mailbox/Makefile b/drivers/mailbox/Makefile
index 2fa343a..7e83a7d 100644
--- a/drivers/mailbox/Makefile
+++ b/drivers/mailbox/Makefile
@@ -9,3 +9,5 @@ obj-$(CONFIG_OMAP1_MBOX)+= mailbox_omap1.o
 mailbox_omap1-objs := mailbox-omap1.o
 obj-$(CONFIG_OMAP2PLUS_MBOX)   += mailbox_omap2.o
 mailbox_omap2-objs := mailbox-omap2.o
+obj-$(CONFIG_SAMSUNG_MBOX) += mailbox_samsung.o
+mailbox_samsung-objs   := mailbox-samsung.o
diff --git a/drivers/mailbox/mailbox-samsung.c 
b/drivers/mailbox/mailbox-samsung.c
new file mode 100644
index 000..903e88a
--- /dev/null
+++ b/drivers/mailbox/mailbox-samsung.c
@@ -0,0 +1,354 @@
+/*
+ * Copyright 2013 Samsung Electronics Co. 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 .
+ */
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+/*
+   Mailbox Register offsets
+ */
+
+/* Offset of tx mailbox data registers */
+#define MBOX_REG_RXDATA0   0
+#define MBOX_REG_RXDATA1   4
+
+/* offset of tx mailbox lock registers */
+#define MBOX_REG_RXLOCK8
+#define MBOX_REG_RXUNLOCK  12
+
+/* offset of tx mailbox interrupt registers */
+#define MBOX_REG_RXINT 16
+
+/* Offset of rx mailbox data registers */
+#define MBOX_REG_TXDATA0   32
+#define MBOX_REG_TXDATA1   36
+
+/* offset of rx mailbox lock registers */
+#define MBOX_REG_TXLOCK40
+#define MBOX_REG_TXUNLOCK  44
+
+/* offset of rx mailbox interrupt registers */
+#define MBOX_REG_TXINT 48
+
+#define MBOX_RX_TX_FULL1
+#define MBOX_INT_ENABLE1
+
+#define MBOX_LOCK_RESET(-1)
+#define MBOX_WAIT_TIMEOUT  (1)
+
+#define RXBUF_LEN  32
+#define MAX_LINKS  1
+
+struct samsung_mlink {
+   const char *name;
+   struct ipc_link link;
+   struct samsung_mbox *smc;
+   int irq;
+   void *data;
+};
+
+struct samsung_mbox {
+   struct device *dev;
+   void __iomem *ipc_base;
+   struct ipc_controller ipc_con;
+   struct mutex lock;
+   struct samsung_mlink samsung_link[MAX_LINKS];
+};
+
+static inline struct samsung_mlink *to_samsung_mlink(struct ipc_link *plink)
+{
+   if (!plink)
+   return NULL;
+
+   return container_of(plink, struct samsung_mlink, link);
+}
+
+static inline struct samsung_mbox *to_samsung_mbox(struct ipc_link *plink)
+{
+   if (!plink)
+   return NULL;
+
+   return to_samsung_mlink(plink)->smc;
+}
+
+static void samsung_mbox_read(struct samsung_mlink *link)
+{
+   u64 data;
+   void __iomem *ipc_base = link->smc->ipc_base;
+
+   /* Read both words which have information specific to client */
+   data = readq(ipc_base + MBOX_REG_RXDATA0);
+   link->data = phys_to_virt((phys_addr_t)data);
+}
+
+static irqreturn_t samsung_ipc_handler(int irq, void *p)
+{
+   struct samsung_mlink *plink = p;
+   void __iomem *ipc_base = plink->smc->ipc_base;
+
+   samsung_mbox_read(plink);
+   ipc_link_received_data(>link, plink->data);
+
+   /* Acknowledge the interrupt 

[PATCH 1/2] mailbox: samsung: added support for samsung mailbox

2014-03-17 Thread Girish K S
This patch adds support to the samsung mailbox driver.

Signed-off-by: Girish K S ks.g...@samsung.com
---
 drivers/mailbox/Kconfig   |8 +
 drivers/mailbox/Makefile  |2 +
 drivers/mailbox/mailbox-samsung.c |  354 +
 include/linux/mailbox-samsung.h   |  112 
 4 files changed, 476 insertions(+)
 create mode 100644 drivers/mailbox/mailbox-samsung.c
 create mode 100644 include/linux/mailbox-samsung.h

diff --git a/drivers/mailbox/Kconfig b/drivers/mailbox/Kconfig
index c8b5c13..bce60ba 100644
--- a/drivers/mailbox/Kconfig
+++ b/drivers/mailbox/Kconfig
@@ -23,6 +23,14 @@ config OMAP_MBOX
  driver such as CONFIG_OMAP1_MBOX or CONFIG_OMAP2PLUS_MBOX. This
  enables the common OMAP mailbox framework code.
 
+config SAMSUNG_MBOX
+   tristate Samsung Mailbox Controller
+   help
+ An implementation of the Samsung Interprocessor Communication
+ Mailbox (IPCM). It is used to send short messages between A57 cores
+ and the System Control Processor or Network Coprocessor firmware.
+ Say Y here if you want to use the Samsung IPCM support.
+
 config OMAP1_MBOX
tristate OMAP1 Mailbox framework support
depends on ARCH_OMAP1
diff --git a/drivers/mailbox/Makefile b/drivers/mailbox/Makefile
index 2fa343a..7e83a7d 100644
--- a/drivers/mailbox/Makefile
+++ b/drivers/mailbox/Makefile
@@ -9,3 +9,5 @@ obj-$(CONFIG_OMAP1_MBOX)+= mailbox_omap1.o
 mailbox_omap1-objs := mailbox-omap1.o
 obj-$(CONFIG_OMAP2PLUS_MBOX)   += mailbox_omap2.o
 mailbox_omap2-objs := mailbox-omap2.o
+obj-$(CONFIG_SAMSUNG_MBOX) += mailbox_samsung.o
+mailbox_samsung-objs   := mailbox-samsung.o
diff --git a/drivers/mailbox/mailbox-samsung.c 
b/drivers/mailbox/mailbox-samsung.c
new file mode 100644
index 000..903e88a
--- /dev/null
+++ b/drivers/mailbox/mailbox-samsung.c
@@ -0,0 +1,354 @@
+/*
+ * Copyright 2013 Samsung Electronics Co. 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/err.h
+#include linux/module.h
+#include linux/slab.h
+#include linux/interrupt.h
+#include linux/io.h
+#include linux/jiffies.h
+#include linux/mailbox_controller.h
+#include linux/mailbox-samsung.h
+#include linux/mutex.h
+#include linux/of.h
+#include linux/of_address.h
+#include linux/of_irq.h
+#include linux/platform_device.h
+
+/*
+   Mailbox Register offsets
+ */
+
+/* Offset of tx mailbox data registers */
+#define MBOX_REG_RXDATA0   0
+#define MBOX_REG_RXDATA1   4
+
+/* offset of tx mailbox lock registers */
+#define MBOX_REG_RXLOCK8
+#define MBOX_REG_RXUNLOCK  12
+
+/* offset of tx mailbox interrupt registers */
+#define MBOX_REG_RXINT 16
+
+/* Offset of rx mailbox data registers */
+#define MBOX_REG_TXDATA0   32
+#define MBOX_REG_TXDATA1   36
+
+/* offset of rx mailbox lock registers */
+#define MBOX_REG_TXLOCK40
+#define MBOX_REG_TXUNLOCK  44
+
+/* offset of rx mailbox interrupt registers */
+#define MBOX_REG_TXINT 48
+
+#define MBOX_RX_TX_FULL1
+#define MBOX_INT_ENABLE1
+
+#define MBOX_LOCK_RESET(-1)
+#define MBOX_WAIT_TIMEOUT  (1)
+
+#define RXBUF_LEN  32
+#define MAX_LINKS  1
+
+struct samsung_mlink {
+   const char *name;
+   struct ipc_link link;
+   struct samsung_mbox *smc;
+   int irq;
+   void *data;
+};
+
+struct samsung_mbox {
+   struct device *dev;
+   void __iomem *ipc_base;
+   struct ipc_controller ipc_con;
+   struct mutex lock;
+   struct samsung_mlink samsung_link[MAX_LINKS];
+};
+
+static inline struct samsung_mlink *to_samsung_mlink(struct ipc_link *plink)
+{
+   if (!plink)
+   return NULL;
+
+   return container_of(plink, struct samsung_mlink, link);
+}
+
+static inline struct samsung_mbox *to_samsung_mbox(struct ipc_link *plink)
+{
+   if (!plink)
+   return NULL;
+
+   return to_samsung_mlink(plink)-smc;
+}
+
+static void samsung_mbox_read(struct samsung_mlink *link)
+{
+   u64 data;
+   void __iomem *ipc_base = link-smc-ipc_base;
+
+   /* Read both words which have information specific to client */
+   data = readq(ipc_base + MBOX_REG_RXDATA0);
+   link-data = phys_to_virt((phys_addr_t)data);
+}
+
+static irqreturn_t samsung_ipc_handler(int irq, void *p)
+{
+