Lines Matching +full:led +full:- +full:heartbeat

1 // SPDX-License-Identifier: GPL-2.0
3 * Generic heartbeat driver for regular LED banks
5 * Copyright (C) 2007 - 2010 Paul Mundt
8 * be independently controlled (either via a pre-defined hardware
9 * function or via the LED class, if desired -- the hardware tends to
10 * encapsulate some of the same "triggers" that the LED class supports,
13 * Additionally, most of these boards also have a LED bank that we've
15 * handled by this driver, rather than giving each LED bit position its
25 #include <asm/heartbeat.h>
27 #define DRV_NAME "heartbeat"
37 new = (1 << hd->bit_pos[bit]); in heartbeat_toggle_bit()
41 new &= hd->mask; in heartbeat_toggle_bit()
43 switch (hd->regsize) { in heartbeat_toggle_bit()
45 new |= ioread32(hd->base) & ~hd->mask; in heartbeat_toggle_bit()
46 iowrite32(new, hd->base); in heartbeat_toggle_bit()
49 new |= ioread16(hd->base) & ~hd->mask; in heartbeat_toggle_bit()
50 iowrite16(new, hd->base); in heartbeat_toggle_bit()
53 new |= ioread8(hd->base) & ~hd->mask; in heartbeat_toggle_bit()
54 iowrite8(new, hd->base); in heartbeat_toggle_bit()
64 heartbeat_toggle_bit(hd, bit, hd->flags & HEARTBEAT_INVERTED); in heartbeat_timer()
67 if ((bit == 0) || (bit == (hd->nr_bits)-1)) in heartbeat_timer()
68 up = -up; in heartbeat_timer()
70 mod_timer(&hd->timer, jiffies + (110 - ((300 << FSHIFT) / in heartbeat_timer()
80 if (unlikely(pdev->num_resources != 1)) { in heartbeat_drv_probe()
81 dev_err(&pdev->dev, "invalid number of resources\n"); in heartbeat_drv_probe()
82 return -EINVAL; in heartbeat_drv_probe()
87 dev_err(&pdev->dev, "invalid resource\n"); in heartbeat_drv_probe()
88 return -EINVAL; in heartbeat_drv_probe()
91 if (pdev->dev.platform_data) { in heartbeat_drv_probe()
92 hd = pdev->dev.platform_data; in heartbeat_drv_probe()
96 return -ENOMEM; in heartbeat_drv_probe()
99 hd->base = ioremap(res->start, resource_size(res)); in heartbeat_drv_probe()
100 if (unlikely(!hd->base)) { in heartbeat_drv_probe()
101 dev_err(&pdev->dev, "ioremap failed\n"); in heartbeat_drv_probe()
103 if (!pdev->dev.platform_data) in heartbeat_drv_probe()
106 return -ENXIO; in heartbeat_drv_probe()
109 if (!hd->nr_bits) { in heartbeat_drv_probe()
110 hd->bit_pos = default_bit_pos; in heartbeat_drv_probe()
111 hd->nr_bits = ARRAY_SIZE(default_bit_pos); in heartbeat_drv_probe()
114 hd->mask = 0; in heartbeat_drv_probe()
115 for (i = 0; i < hd->nr_bits; i++) in heartbeat_drv_probe()
116 hd->mask |= (1 << hd->bit_pos[i]); in heartbeat_drv_probe()
118 if (!hd->regsize) { in heartbeat_drv_probe()
119 switch (res->flags & IORESOURCE_MEM_TYPE_MASK) { in heartbeat_drv_probe()
121 hd->regsize = 32; in heartbeat_drv_probe()
124 hd->regsize = 16; in heartbeat_drv_probe()
128 hd->regsize = 8; in heartbeat_drv_probe()
133 timer_setup(&hd->timer, heartbeat_timer, 0); in heartbeat_drv_probe()
136 return mod_timer(&hd->timer, jiffies + 1); in heartbeat_drv_probe()