提交 d027ebc9 编写于 作者: F Fang Yafen 提交者: Zheng Zengkai

gpio:keep the original function for non-RPi

raspberrypi inclusion
category: feature
bugzilla: 50432

------------------------------

This patch adjusts following gpio related patches for
raspberry pi on non-Raspberry Pi platforms, using specific
config CONFIG_OPENEULER_RASPBERRYPI to distinguish them:

680d5826 Revert "mailbox: avoid timer start from callback"
1088c5d4 gpiolib: Don't prevent IRQ usage of output GPIOs
54bc28b4 gpio-poweroff: Allow it to work on Raspberry Pi
26b77aae i2c-gpio: Also set bus numbers from reg property
Signed-off-by: NFang Yafen <yafen@iscas.ac.cn>
Reviewed-by: NXie XiuQi <xiexiuqi@huawei.com>
Signed-off-by: NZheng Zengkai <zhengzengkai@huawei.com>
上级 fef4c142
......@@ -51,8 +51,6 @@
#define extra_checks 0
#endif
#define dont_test_bit(b,d) (0)
/* Device and char device-related information */
static DEFINE_IDA(gpio_ida);
static dev_t gpio_devt;
......@@ -2439,13 +2437,15 @@ int gpiod_direction_output(struct gpio_desc *desc, int value)
value = !!value;
/* GPIOs used for enabled IRQs shall not be set as output */
if (dont_test_bit(FLAG_USED_AS_IRQ, &desc->flags) &&
dont_test_bit(FLAG_IRQ_IS_ENABLED, &desc->flags)) {
#ifndef CONFIG_OPENEULER_RASPBERRYPI
if (test_bit(FLAG_USED_AS_IRQ, &desc->flags) &&
test_bit(FLAG_IRQ_IS_ENABLED, &desc->flags)) {
gpiod_err(desc,
"%s: tried to set a GPIO tied to an IRQ as output\n",
__func__);
return -EIO;
}
#endif
if (test_bit(FLAG_OPEN_DRAIN, &desc->flags)) {
/* First see if we can enable open drain in hardware */
......@@ -3245,13 +3245,15 @@ int gpiochip_lock_as_irq(struct gpio_chip *gc, unsigned int offset)
}
/* To be valid for IRQ the line needs to be input or open drain */
if (dont_test_bit(FLAG_IS_OUT, &desc->flags) &&
!dont_test_bit(FLAG_OPEN_DRAIN, &desc->flags)) {
#ifndef CONFIG_OPENEULER_RASPBERRYPI
if (test_bit(FLAG_IS_OUT, &desc->flags) &&
!test_bit(FLAG_OPEN_DRAIN, &desc->flags)) {
chip_err(gc,
"%s: tried to flag a GPIO set as output for IRQ\n",
__func__);
return -EIO;
}
#endif
set_bit(FLAG_USED_AS_IRQ, &desc->flags);
set_bit(FLAG_IRQ_IS_ENABLED, &desc->flags);
......
......@@ -445,9 +445,13 @@ static int i2c_gpio_probe(struct platform_device *pdev)
adap->dev.parent = dev;
adap->dev.of_node = np;
#ifdef CONFIG_OPENEULER_RASPBERRYPI
if (pdev->id != PLATFORM_DEVID_NONE || !pdev->dev.of_node ||
of_property_read_u32(pdev->dev.of_node, "reg", &adap->nr))
adap->nr = pdev->id;
#else
adap->nr = pdev->id;
#endif
ret = i2c_bit_add_numbered_bus(adap);
if (ret)
return ret;
......
......@@ -82,9 +82,16 @@ static void msg_submit(struct mbox_chan *chan)
exit:
spin_unlock_irqrestore(&chan->lock, flags);
if (!err && (chan->txdone_method & TXDONE_BY_POLL))
/* kick start the timer immediately to avoid delays */
if (!err && (chan->txdone_method & TXDONE_BY_POLL)) {
#ifdef CONFIG_OPENEULER_RASPBERRYPI
hrtimer_start(&chan->mbox->poll_hrt, 0, HRTIMER_MODE_REL);
#else
/* but only if not already active */
if (!hrtimer_active(&chan->mbox->poll_hrt))
hrtimer_start(&chan->mbox->poll_hrt, 0, HRTIMER_MODE_REL);
#endif
}
}
static void tx_tick(struct mbox_chan *chan, int r)
......@@ -122,6 +129,9 @@ static enum hrtimer_restart txdone_hrtimer(struct hrtimer *hrtimer)
struct mbox_chan *chan = &mbox->chans[i];
if (chan->active_req && chan->cl) {
#ifndef CONFIG_OPENEULER_RASPBERRYPI
resched = true;
#endif
txdone = chan->mbox->ops->last_tx_done(chan);
if (txdone)
tx_tick(chan, 0);
......
......@@ -54,7 +54,9 @@ static int gpio_poweroff_probe(struct platform_device *pdev)
bool export = false;
/* If a pm_power_off function has already been added, leave it alone */
#ifdef CONFIG_OPENEULER_RASPBERRYPI
force = of_property_read_bool(pdev->dev.of_node, "force");
#endif
if (!force && (pm_power_off != NULL)) {
dev_err(&pdev->dev,
"%s: pm_power_off function already registered\n",
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册