History

Merge branch 'mailbox-for-next' of git://git.linaro.org/landing-teams/working/fujitsu/integration

Pull mailbox updates from Jassi Brar: "OMAP: - Remove non-DT support from mailbox driver - Move PM from client calls to native driver suspend/resume - Trivial cleanups to make checkpatch happy STI: - Check return from devm_ioremap_resource as ERR_PTR, not NULL" * 'mailbox-for-next' of git://git.linaro.org/landing-teams/working/fujitsu/integration: mailbox: Fix devm_ioremap_resource error detection code mailbox/omap: kill omap_mbox_{save/restore}_ctx() functions mailbox/omap: check for any unread messages during suspend mailbox/omap: add support for suspend/resume mailbox/omap: store mailbox interrupt type in omap_mbox_device mailbox/omap: add blank lines after declarations mailbox/omap: remove FSF mailing address paragraph mailbox/omap: use variable name for sizeof() operator mailbox/omap: drop legacy platform device support

Linus Torvalds committed 10 years ago

Commit 10cd7152 parents 51e68d0 c430cf34 files · +104 −180Browse files

Unified · Split

4 files
  1. drivers/mailbox/mailbox-sti.c +2 −2
  2. drivers/mailbox/omap-mailbox.c +102 −118
  3. include/linux/omap-mailbox.h +0 −2
  4. include/linux/platform_data/mailbox-omap.h +0 −58
drivers/mailbox/mailbox-sti.c+2−2
@@ -430,8 +430,8 @@ static int sti_mbox_probe(struct platform_device *pdev) · 429 unmodified lines
430430
431431 res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
432432 mdev->base = devm_ioremap_resource(&pdev->dev, res);
433− if (!mdev->base)
434− return -ENOMEM;
433+ if (IS_ERR(mdev->base))
434+ return PTR_ERR(mdev->base);
435435
436436 ret = of_property_read_string(np, "mbox-name", &mdev->name);
437437 if (ret)
drivers/mailbox/omap-mailbox.c+102−118
@@ -2,7 +2,7 @@ · 1 unmodified line
22 * OMAP mailbox driver
33 *
44 * Copyright (C) 2006-2009 Nokia Corporation. All rights reserved.
5− * Copyright (C) 2013-2014 Texas Instruments Inc.
5+ * Copyright (C) 2013-2016 Texas Instruments Incorporated - http://www.ti.com
66 *
77 * Contact: Hiroshi DOYU <Hiroshi.DOYU@nokia.com>
88 * Suman Anna <s-anna@ti.com>
@@ -15,12 +15,6 @@ · 6 unmodified lines
1515 * WITHOUT ANY WARRANTY; without even the implied warranty of
1616 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
1717 * General Public License for more details.
18− *
19− * You should have received a copy of the GNU General Public License
20− * along with this program; if not, write to the Free Software
21− * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
22− * 02110-1301 USA
23− *
2418 */
2519
2620 #include <linux/interrupt.h>
@@ -33,7 +27,6 @@ · 6 unmodified lines
3327 #include <linux/of_device.h>
3428 #include <linux/platform_device.h>
3529 #include <linux/pm_runtime.h>
36−#include <linux/platform_data/mailbox-omap.h>
3730 #include <linux/omap-mailbox.h>
3831 #include <linux/mailbox_controller.h>
3932 #include <linux/mailbox_client.h>
@@ -62,12 +55,9 @@ · 22 unmodified lines
6255 #define MAILBOX_IRQ_NEWMSG(m) (1 << (2 * (m)))
6356 #define MAILBOX_IRQ_NOTFULL(m) (1 << (2 * (m) + 1))
6457
65−#define MBOX_REG_SIZE 0x120
66−
67−#define OMAP4_MBOX_REG_SIZE 0x130
68−
69−#define MBOX_NR_REGS (MBOX_REG_SIZE / sizeof(u32))
70−#define OMAP4_MBOX_NR_REGS (OMAP4_MBOX_REG_SIZE / sizeof(u32))
58+/* Interrupt register configuration types */
59+#define MBOX_INTR_CFG_TYPE1 0
60+#define MBOX_INTR_CFG_TYPE2 1
7161
7262 struct omap_mbox_fifo {
7363 unsigned long msg;
@@ -91,8 +81,10 @@ struct omap_mbox_device { · 17 unmodified lines
9181 struct device *dev;
9282 struct mutex cfg_lock;
9383 void __iomem *mbox_base;
84+ u32 *irq_ctx;
9485 u32 num_users;
9586 u32 num_fifos;
87+ u32 intr_type;
9688 struct omap_mbox **mboxes;
9789 struct mbox_controller controller;
9890 struct list_head elem;
@@ -119,7 +111,6 @@ struct omap_mbox { · 20 unmodified lines
119111 struct omap_mbox_device *parent;
120112 struct omap_mbox_fifo tx_fifo;
121113 struct omap_mbox_fifo rx_fifo;
122− u32 ctx[OMAP4_MBOX_NR_REGS];
123114 u32 intr_type;
124115 struct mbox_chan *chan;
125116 bool send_no_irq;
@@ -157,24 +148,28 @@ void mbox_write_reg(struct omap_mbox_device *mdev, u32 val, size_t ofs) · 31 unmodified lines
157148 static mbox_msg_t mbox_fifo_read(struct omap_mbox *mbox)
158149 {
159150 struct omap_mbox_fifo *fifo = &mbox->rx_fifo;
160− return (mbox_msg_t) mbox_read_reg(mbox->parent, fifo->msg);
151+
152+ return (mbox_msg_t)mbox_read_reg(mbox->parent, fifo->msg);
161153 }
162154
163155 static void mbox_fifo_write(struct omap_mbox *mbox, mbox_msg_t msg)
164156 {
165157 struct omap_mbox_fifo *fifo = &mbox->tx_fifo;
158+
166159 mbox_write_reg(mbox->parent, msg, fifo->msg);
167160 }
168161
169162 static int mbox_fifo_empty(struct omap_mbox *mbox)
170163 {
171164 struct omap_mbox_fifo *fifo = &mbox->rx_fifo;
165+
172166 return (mbox_read_reg(mbox->parent, fifo->msg_stat) == 0);
173167 }
174168
175169 static int mbox_fifo_full(struct omap_mbox *mbox)
176170 {
177171 struct omap_mbox_fifo *fifo = &mbox->tx_fifo;
172+
178173 return mbox_read_reg(mbox->parent, fifo->fifo_stat);
179174 }
180175
@@ -206,49 +201,6 @@ static int is_mbox_irq(struct omap_mbox *mbox, omap_mbox_irq_t irq) · 25 unmodified lines
206201 return (int)(enable & status & bit);
207202 }
208203
209−void omap_mbox_save_ctx(struct mbox_chan *chan)
210−{
211− int i;
212− int nr_regs;
213− struct omap_mbox *mbox = mbox_chan_to_omap_mbox(chan);
214−
215− if (WARN_ON(!mbox))
216− return;
217−
218− if (mbox->intr_type)
219− nr_regs = OMAP4_MBOX_NR_REGS;
220− else
221− nr_regs = MBOX_NR_REGS;
222− for (i = 0; i < nr_regs; i++) {
223− mbox->ctx[i] = mbox_read_reg(mbox->parent, i * sizeof(u32));
224−
225− dev_dbg(mbox->dev, "%s: [%02x] %08x\n", __func__,
226− i, mbox->ctx[i]);
227− }
228−}
229−EXPORT_SYMBOL(omap_mbox_save_ctx);
230−
231−void omap_mbox_restore_ctx(struct mbox_chan *chan)
232−{
233− int i;
234− int nr_regs;
235− struct omap_mbox *mbox = mbox_chan_to_omap_mbox(chan);
236−
237− if (WARN_ON(!mbox))
238− return;
239−
240− if (mbox->intr_type)
241− nr_regs = OMAP4_MBOX_NR_REGS;
242− else
243− nr_regs = MBOX_NR_REGS;
244− for (i = 0; i < nr_regs; i++) {
245− mbox_write_reg(mbox->parent, mbox->ctx[i], i * sizeof(u32));
246− dev_dbg(mbox->dev, "%s: [%02x] %08x\n", __func__,
247− i, mbox->ctx[i]);
248− }
249−}
250−EXPORT_SYMBOL(omap_mbox_restore_ctx);
251−
252204 static void _omap_mbox_enable_irq(struct omap_mbox *mbox, omap_mbox_irq_t irq)
253205 {
254206 u32 l;
@@ -381,7 +333,7 @@ static struct omap_mbox_queue *mbox_queue_alloc(struct omap_mbox *mbox, · 126 unmodified lines
381333 if (!work)
382334 return NULL;
383335
384− mq = kzalloc(sizeof(struct omap_mbox_queue), GFP_KERNEL);
336+ mq = kzalloc(sizeof(*mq), GFP_KERNEL);
385337 if (!mq)
386338 return NULL;
387339
@@ -525,6 +477,7 @@ static int omap_mbox_register(struct omap_mbox_device *mdev) · 137 unmodified lines
525477 mboxes = mdev->mboxes;
526478 for (i = 0; mboxes[i]; i++) {
527479 struct omap_mbox *mbox = mboxes[i];
480+
528481 mbox->dev = device_create(&omap_mbox_class, mdev->dev,
529482 0, mbox, "%s", mbox->name);
530483 if (IS_ERR(mbox->dev)) {
@@ -647,6 +600,52 @@ static const struct mbox_chan_ops omap_mbox_chan_ops = { · 116 unmodified lines
647600 .shutdown = omap_mbox_chan_shutdown,
648601 };
649602
603+#ifdef CONFIG_PM_SLEEP
604+static int omap_mbox_suspend(struct device *dev)
605+{
606+ struct omap_mbox_device *mdev = dev_get_drvdata(dev);
607+ u32 usr, fifo, reg;
608+
609+ if (pm_runtime_status_suspended(dev))
610+ return 0;
611+
612+ for (fifo = 0; fifo < mdev->num_fifos; fifo++) {
613+ if (mbox_read_reg(mdev, MAILBOX_MSGSTATUS(fifo))) {
614+ dev_err(mdev->dev, "fifo %d has unexpected unread messages\n",
615+ fifo);
616+ return -EBUSY;
617+ }
618+ }
619+
620+ for (usr = 0; usr < mdev->num_users; usr++) {
621+ reg = MAILBOX_IRQENABLE(mdev->intr_type, usr);
622+ mdev->irq_ctx[usr] = mbox_read_reg(mdev, reg);
623+ }
624+
625+ return 0;
626+}
627+
628+static int omap_mbox_resume(struct device *dev)
629+{
630+ struct omap_mbox_device *mdev = dev_get_drvdata(dev);
631+ u32 usr, reg;
632+
633+ if (pm_runtime_status_suspended(dev))
634+ return 0;
635+
636+ for (usr = 0; usr < mdev->num_users; usr++) {
637+ reg = MAILBOX_IRQENABLE(mdev->intr_type, usr);
638+ mbox_write_reg(mdev, mdev->irq_ctx[usr], reg);
639+ }
640+
641+ return 0;
642+}
643+#endif
644+
645+static const struct dev_pm_ops omap_mbox_pm_ops = {
646+ SET_SYSTEM_SLEEP_PM_OPS(omap_mbox_suspend, omap_mbox_resume)
647+};
648+
650649 static const struct of_device_id omap_mailbox_of_match[] = {
651650 {
652651 .compatible = "ti,omap2-mailbox",
@@ -696,8 +695,6 @@ static int omap_mbox_probe(struct platform_device *pdev) · 43 unmodified lines
696695 int ret;
697696 struct mbox_chan *chnls;
698697 struct omap_mbox **list, *mbox, *mboxblk;
699− struct omap_mbox_pdata *pdata = pdev->dev.platform_data;
700− struct omap_mbox_dev_info *info = NULL;
701698 struct omap_mbox_fifo_info *finfo, *finfoblk;
702699 struct omap_mbox_device *mdev;
703700 struct omap_mbox_fifo *fifo;
@@ -710,36 +707,26 @@ static int omap_mbox_probe(struct platform_device *pdev) · 6 unmodified lines
710707 u32 l;
711708 int i;
712709
713− if (!node && (!pdata || !pdata->info_cnt || !pdata->info)) {
714− pr_err("%s: platform not supported\n", __func__);
710+ if (!node) {
711+ pr_err("%s: only DT-based devices are supported\n", __func__);
715712 return -ENODEV;
716713 }
717714
718− if (node) {
719− match = of_match_device(omap_mailbox_of_match, &pdev->dev);
720− if (!match)
721− return -ENODEV;
722− intr_type = (u32)match->data;
715+ match = of_match_device(omap_mailbox_of_match, &pdev->dev);
716+ if (!match)
717+ return -ENODEV;
718+ intr_type = (u32)match->data;
723719
724− if (of_property_read_u32(node, "ti,mbox-num-users",
725− &num_users))
726− return -ENODEV;
720+ if (of_property_read_u32(node, "ti,mbox-num-users", &num_users))
721+ return -ENODEV;
727722
728− if (of_property_read_u32(node, "ti,mbox-num-fifos",
729− &num_fifos))
730− return -ENODEV;
723+ if (of_property_read_u32(node, "ti,mbox-num-fifos", &num_fifos))
724+ return -ENODEV;
731725
732− info_count = of_get_available_child_count(node);
733− if (!info_count) {
734− dev_err(&pdev->dev, "no available mbox devices found\n");
735− return -ENODEV;
736− }
737− } else { /* non-DT device creation */
738− info_count = pdata->info_cnt;
739− info = pdata->info;
740− intr_type = pdata->intr_type;
741− num_users = pdata->num_users;
742− num_fifos = pdata->num_fifos;
726+ info_count = of_get_available_child_count(node);
727+ if (!info_count) {
728+ dev_err(&pdev->dev, "no available mbox devices found\n");
729+ return -ENODEV;
743730 }
744731
745732 finfoblk = devm_kzalloc(&pdev->dev, info_count * sizeof(*finfoblk),
@@ -750,38 +737,28 @@ static int omap_mbox_probe(struct platform_device *pdev) · 4 unmodified lines
750737 finfo = finfoblk;
751738 child = NULL;
752739 for (i = 0; i < info_count; i++, finfo++) {
753− if (node) {
754− child = of_get_next_available_child(node, child);
755− ret = of_property_read_u32_array(child, "ti,mbox-tx",
756− tmp, ARRAY_SIZE(tmp));
757− if (ret)
758− return ret;
759− finfo->tx_id = tmp[0];
760− finfo->tx_irq = tmp[1];
761− finfo->tx_usr = tmp[2];
762−
763− ret = of_property_read_u32_array(child, "ti,mbox-rx",
764− tmp, ARRAY_SIZE(tmp));
765− if (ret)
766− return ret;
767− finfo->rx_id = tmp[0];
768− finfo->rx_irq = tmp[1];
769− finfo->rx_usr = tmp[2];
770−
771− finfo->name = child->name;
772−
773− if (of_find_property(child, "ti,mbox-send-noirq", NULL))
774− finfo->send_no_irq = true;
775− } else {
776− finfo->tx_id = info->tx_id;
777− finfo->rx_id = info->rx_id;
778− finfo->tx_usr = info->usr_id;
779− finfo->tx_irq = info->irq_id;
780− finfo->rx_usr = info->usr_id;
781− finfo->rx_irq = info->irq_id;
782− finfo->name = info->name;
783− info++;
784− }
740+ child = of_get_next_available_child(node, child);
741+ ret = of_property_read_u32_array(child, "ti,mbox-tx", tmp,
742+ ARRAY_SIZE(tmp));
743+ if (ret)
744+ return ret;
745+ finfo->tx_id = tmp[0];
746+ finfo->tx_irq = tmp[1];
747+ finfo->tx_usr = tmp[2];
748+
749+ ret = of_property_read_u32_array(child, "ti,mbox-rx", tmp,
750+ ARRAY_SIZE(tmp));
751+ if (ret)
752+ return ret;
753+ finfo->rx_id = tmp[0];
754+ finfo->rx_irq = tmp[1];
755+ finfo->rx_usr = tmp[2];
756+
757+ finfo->name = child->name;
758+
759+ if (of_find_property(child, "ti,mbox-send-noirq", NULL))
760+ finfo->send_no_irq = true;
761+
785762 if (finfo->tx_id >= num_fifos || finfo->rx_id >= num_fifos ||
786763 finfo->tx_usr >= num_users || finfo->rx_usr >= num_users)
787764 return -EINVAL;
@@ -796,6 +773,11 @@ static int omap_mbox_probe(struct platform_device *pdev) · 8 unmodified lines
796773 if (IS_ERR(mdev->mbox_base))
797774 return PTR_ERR(mdev->mbox_base);
798775
776+ mdev->irq_ctx = devm_kzalloc(&pdev->dev, num_users * sizeof(u32),
777+ GFP_KERNEL);
778+ if (!mdev->irq_ctx)
779+ return -ENOMEM;
780+
799781 /* allocate one extra for marking end of list */
800782 list = devm_kzalloc(&pdev->dev, (info_count + 1) * sizeof(*list),
801783 GFP_KERNEL);
@@ -848,6 +830,7 @@ static int omap_mbox_probe(struct platform_device *pdev) · 46 unmodified lines
848830 mdev->dev = &pdev->dev;
849831 mdev->num_users = num_users;
850832 mdev->num_fifos = num_fifos;
833+ mdev->intr_type = intr_type;
851834 mdev->mboxes = list;
852835
853836 /* OMAP does not have a Tx-Done IRQ, but rather a Tx-Ready IRQ */
@@ -905,6 +888,7 @@ static struct platform_driver omap_mbox_driver = { · 51 unmodified lines
905888 .remove = omap_mbox_remove,
906889 .driver = {
907890 .name = "omap-mailbox",
891+ .pm = &omap_mbox_pm_ops,
908892 .of_match_table = of_match_ptr(omap_mailbox_of_match),
909893 },
910894 };
include/linux/omap-mailbox.h+0−2
@@ -21,8 +21,6 @@ struct mbox_client; · 20 unmodified lines
2121 struct mbox_chan *omap_mbox_request_channel(struct mbox_client *cl,
2222 const char *chan_name);
2323
24−void omap_mbox_save_ctx(struct mbox_chan *chan);
25−void omap_mbox_restore_ctx(struct mbox_chan *chan);
2624 void omap_mbox_enable_irq(struct mbox_chan *chan, omap_mbox_irq_t irq);
2725 void omap_mbox_disable_irq(struct mbox_chan *chan, omap_mbox_irq_t irq);
2826
include/linux/platform_data/mailbox-omap.h+0−58
@@ -1,58 +0,0 @@
1−/*
2− * mailbox-omap.h
3− *
4− * Copyright (C) 2013 Texas Instruments, Inc.
5− *
6− * This program is free software; you can redistribute it and/or
7− * modify it under the terms of the GNU General Public License
8− * version 2 as published by the Free Software Foundation.
9− *
10− * This program is distributed in the hope that it will be useful,
11− * but WITHOUT ANY WARRANTY; without even the implied warranty of
12− * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13− * GNU General Public License for more details.
14− */
15−
16−#ifndef _PLAT_MAILBOX_H
17−#define _PLAT_MAILBOX_H
18−
19−/* Interrupt register configuration types */
20−#define MBOX_INTR_CFG_TYPE1 (0)
21−#define MBOX_INTR_CFG_TYPE2 (1)
22−
23−/**
24− * struct omap_mbox_dev_info - OMAP mailbox device attribute info
25− * @name: name of the mailbox device
26− * @tx_id: mailbox queue id used for transmitting messages
27− * @rx_id: mailbox queue id on which messages are received
28− * @irq_id: irq identifier number to use from the hwmod data
29− * @usr_id: mailbox user id for identifying the interrupt into
30− * the MPU interrupt controller.
31− */
32−struct omap_mbox_dev_info {
33− const char *name;
34− u32 tx_id;
35− u32 rx_id;
36− u32 irq_id;
37− u32 usr_id;
38−};
39−
40−/**
41− * struct omap_mbox_pdata - OMAP mailbox platform data
42− * @intr_type: type of interrupt configuration registers used
43− while programming mailbox queue interrupts
44− * @num_users: number of users (processor devices) that the mailbox
45− * h/w block can interrupt
46− * @num_fifos: number of h/w fifos within the mailbox h/w block
47− * @info_cnt: number of mailbox devices for the platform
48− * @info: array of mailbox device attributes
49− */
50−struct omap_mbox_pdata {
51− u32 intr_type;
52− u32 num_users;
53− u32 num_fifos;
54− u32 info_cnt;
55− struct omap_mbox_dev_info *info;
56−};
57−
58−#endif /* _PLAT_MAILBOX_H */