Lines Matching +full:pwr +full:- +full:reg

4  * Based on twl4030-pwrbutton driver by:
5 * Peter De Schrijver <peter.de-schrijver@nokia.com>
19 * Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335 USA
33 struct input_dev *pwr; member
60 mc13xxx_irq_ack(priv->mc13783, irq); in button_irq()
61 mc13xxx_reg_read(priv->mc13783, MC13783_REG_INTERRUPT_SENSE_1, &val); in button_irq()
66 if (priv->flags & MC13783_PWRB_B1_POL_INVERT) in button_irq()
68 input_report_key(priv->pwr, priv->keymap[0], val); in button_irq()
73 if (priv->flags & MC13783_PWRB_B2_POL_INVERT) in button_irq()
75 input_report_key(priv->pwr, priv->keymap[1], val); in button_irq()
80 if (priv->flags & MC13783_PWRB_B3_POL_INVERT) in button_irq()
82 input_report_key(priv->pwr, priv->keymap[2], val); in button_irq()
86 input_sync(priv->pwr); in button_irq()
94 struct mc13xxx *mc13783 = dev_get_drvdata(pdev->dev.parent); in mc13783_pwrbutton_probe()
95 struct input_dev *pwr; in mc13783_pwrbutton_probe() local
98 int reg = 0; in mc13783_pwrbutton_probe() local
100 pdata = dev_get_platdata(&pdev->dev); in mc13783_pwrbutton_probe()
102 dev_err(&pdev->dev, "missing platform data\n"); in mc13783_pwrbutton_probe()
103 return -ENODEV; in mc13783_pwrbutton_probe()
106 pwr = input_allocate_device(); in mc13783_pwrbutton_probe()
107 if (!pwr) { in mc13783_pwrbutton_probe()
108 dev_dbg(&pdev->dev, "Can't allocate power button\n"); in mc13783_pwrbutton_probe()
109 return -ENOMEM; in mc13783_pwrbutton_probe()
114 err = -ENOMEM; in mc13783_pwrbutton_probe()
115 dev_dbg(&pdev->dev, "Can't allocate power button\n"); in mc13783_pwrbutton_probe()
119 reg |= (pdata->b1on_flags & 0x3) << MC13783_POWER_CONTROL_2_ON1BDBNC; in mc13783_pwrbutton_probe()
120 reg |= (pdata->b2on_flags & 0x3) << MC13783_POWER_CONTROL_2_ON2BDBNC; in mc13783_pwrbutton_probe()
121 reg |= (pdata->b3on_flags & 0x3) << MC13783_POWER_CONTROL_2_ON3BDBNC; in mc13783_pwrbutton_probe()
123 priv->pwr = pwr; in mc13783_pwrbutton_probe()
124 priv->mc13783 = mc13783; in mc13783_pwrbutton_probe()
128 if (pdata->b1on_flags & MC13783_BUTTON_ENABLE) { in mc13783_pwrbutton_probe()
129 priv->keymap[0] = pdata->b1on_key; in mc13783_pwrbutton_probe()
130 if (pdata->b1on_key != KEY_RESERVED) in mc13783_pwrbutton_probe()
131 __set_bit(pdata->b1on_key, pwr->keybit); in mc13783_pwrbutton_probe()
133 if (pdata->b1on_flags & MC13783_BUTTON_POL_INVERT) in mc13783_pwrbutton_probe()
134 priv->flags |= MC13783_PWRB_B1_POL_INVERT; in mc13783_pwrbutton_probe()
136 if (pdata->b1on_flags & MC13783_BUTTON_RESET_EN) in mc13783_pwrbutton_probe()
137 reg |= MC13783_POWER_CONTROL_2_ON1BRSTEN; in mc13783_pwrbutton_probe()
142 dev_dbg(&pdev->dev, "Can't request irq\n"); in mc13783_pwrbutton_probe()
147 if (pdata->b2on_flags & MC13783_BUTTON_ENABLE) { in mc13783_pwrbutton_probe()
148 priv->keymap[1] = pdata->b2on_key; in mc13783_pwrbutton_probe()
149 if (pdata->b2on_key != KEY_RESERVED) in mc13783_pwrbutton_probe()
150 __set_bit(pdata->b2on_key, pwr->keybit); in mc13783_pwrbutton_probe()
152 if (pdata->b2on_flags & MC13783_BUTTON_POL_INVERT) in mc13783_pwrbutton_probe()
153 priv->flags |= MC13783_PWRB_B2_POL_INVERT; in mc13783_pwrbutton_probe()
155 if (pdata->b2on_flags & MC13783_BUTTON_RESET_EN) in mc13783_pwrbutton_probe()
156 reg |= MC13783_POWER_CONTROL_2_ON2BRSTEN; in mc13783_pwrbutton_probe()
161 dev_dbg(&pdev->dev, "Can't request irq\n"); in mc13783_pwrbutton_probe()
166 if (pdata->b3on_flags & MC13783_BUTTON_ENABLE) { in mc13783_pwrbutton_probe()
167 priv->keymap[2] = pdata->b3on_key; in mc13783_pwrbutton_probe()
168 if (pdata->b3on_key != KEY_RESERVED) in mc13783_pwrbutton_probe()
169 __set_bit(pdata->b3on_key, pwr->keybit); in mc13783_pwrbutton_probe()
171 if (pdata->b3on_flags & MC13783_BUTTON_POL_INVERT) in mc13783_pwrbutton_probe()
172 priv->flags |= MC13783_PWRB_B3_POL_INVERT; in mc13783_pwrbutton_probe()
174 if (pdata->b3on_flags & MC13783_BUTTON_RESET_EN) in mc13783_pwrbutton_probe()
175 reg |= MC13783_POWER_CONTROL_2_ON3BRSTEN; in mc13783_pwrbutton_probe()
180 dev_dbg(&pdev->dev, "Can't request irq: %d\n", err); in mc13783_pwrbutton_probe()
185 mc13xxx_reg_rmw(mc13783, MC13783_REG_POWER_CONTROL_2, 0x3FE, reg); in mc13783_pwrbutton_probe()
189 pwr->name = "mc13783_pwrbutton"; in mc13783_pwrbutton_probe()
190 pwr->phys = "mc13783_pwrbutton/input0"; in mc13783_pwrbutton_probe()
191 pwr->dev.parent = &pdev->dev; in mc13783_pwrbutton_probe()
193 pwr->keycode = priv->keymap; in mc13783_pwrbutton_probe()
194 pwr->keycodemax = ARRAY_SIZE(priv->keymap); in mc13783_pwrbutton_probe()
195 pwr->keycodesize = sizeof(priv->keymap[0]); in mc13783_pwrbutton_probe()
196 __set_bit(EV_KEY, pwr->evbit); in mc13783_pwrbutton_probe()
198 err = input_register_device(pwr); in mc13783_pwrbutton_probe()
200 dev_dbg(&pdev->dev, "Can't register power button: %d\n", err); in mc13783_pwrbutton_probe()
211 if (pdata->b3on_flags & MC13783_BUTTON_ENABLE) in mc13783_pwrbutton_probe()
215 if (pdata->b2on_flags & MC13783_BUTTON_ENABLE) in mc13783_pwrbutton_probe()
219 if (pdata->b1on_flags & MC13783_BUTTON_ENABLE) in mc13783_pwrbutton_probe()
227 input_free_device(pwr); in mc13783_pwrbutton_probe()
237 pdata = dev_get_platdata(&pdev->dev); in mc13783_pwrbutton_remove()
239 mc13xxx_lock(priv->mc13783); in mc13783_pwrbutton_remove()
241 if (pdata->b3on_flags & MC13783_BUTTON_ENABLE) in mc13783_pwrbutton_remove()
242 mc13xxx_irq_free(priv->mc13783, MC13783_IRQ_ONOFD3, priv); in mc13783_pwrbutton_remove()
243 if (pdata->b2on_flags & MC13783_BUTTON_ENABLE) in mc13783_pwrbutton_remove()
244 mc13xxx_irq_free(priv->mc13783, MC13783_IRQ_ONOFD2, priv); in mc13783_pwrbutton_remove()
245 if (pdata->b1on_flags & MC13783_BUTTON_ENABLE) in mc13783_pwrbutton_remove()
246 mc13xxx_irq_free(priv->mc13783, MC13783_IRQ_ONOFD1, priv); in mc13783_pwrbutton_remove()
248 mc13xxx_unlock(priv->mc13783); in mc13783_pwrbutton_remove()
250 input_unregister_device(priv->pwr); in mc13783_pwrbutton_remove()
260 .name = "mc13783-pwrbutton",
266 MODULE_ALIAS("platform:mc13783-pwrbutton");