Lines Matching +full:use +full:- +full:broken +full:- +full:interrupts
5 * Redistribution and use in source and binary forms, with or without
21 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
24 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
57 helper->props = mmc_helper.props; in mmc_fdt_parse()
63 if (regulator_get_by_ofw_property(dev, 0, "vmmc-supply", in mmc_fdt_parse()
64 &helper->vmmc_supply) == 0) { in mmc_fdt_parse()
66 device_printf(dev, "vmmc-supply regulator found\n"); in mmc_fdt_parse()
68 if (regulator_get_by_ofw_property(dev, 0, "vqmmc-supply", in mmc_fdt_parse()
69 &helper->vqmmc_supply) == 0) { in mmc_fdt_parse()
71 device_printf(dev, "vqmmc-supply regulator found\n"); in mmc_fdt_parse()
74 if (helper->vqmmc_supply != NULL) { in mmc_fdt_parse()
75 if (regulator_check_voltage(helper->vqmmc_supply, 1200000) == 0) in mmc_fdt_parse()
76 host->caps |= MMC_CAP_SIGNALING_120; in mmc_fdt_parse()
78 host->caps &= ~( MMC_CAP_MMC_HS400_120 | in mmc_fdt_parse()
81 if (regulator_check_voltage(helper->vqmmc_supply, 1800000) == 0) in mmc_fdt_parse()
82 host->caps |= MMC_CAP_SIGNALING_180; in mmc_fdt_parse()
84 host->caps &= ~(MMC_CAP_MMC_HS400_180 | in mmc_fdt_parse()
91 if (regulator_check_voltage(helper->vqmmc_supply, 3300000) == 0) in mmc_fdt_parse()
92 host->caps |= MMC_CAP_SIGNALING_330; in mmc_fdt_parse()
94 host->caps |= MMC_CAP_SIGNALING_330; in mmc_fdt_parse()
96 if (OF_hasprop(node, "mmc-pwrseq")) { in mmc_fdt_parse()
97 if (OF_getencprop(node, "mmc-pwrseq", &pwrseq_xref, sizeof(pwrseq_xref)) == -1) { in mmc_fdt_parse()
101 helper->mmc_pwrseq = OF_device_from_xref(pwrseq_xref); in mmc_fdt_parse()
115 &helper->cd_delayed_task, -(hz / 2)); in cd_intr()
125 if(helper->cd_handler && cd_present != helper->cd_present) in cd_card_task()
126 helper->cd_handler(helper->dev, in cd_card_task()
128 helper->cd_present = cd_present; in cd_card_task()
130 /* If we're polling re-schedule the task */ in cd_card_task()
131 if (helper->cd_ihandler == NULL) in cd_card_task()
133 &helper->cd_delayed_task, mstosbt(500), 0, C_PREL(2)); in cd_card_task()
146 dev = helper->dev; in cd_setup()
148 TIMEOUT_TASK_INIT(taskqueue_bus, &helper->cd_delayed_task, 0, in cd_setup()
152 * If the device is flagged as non-removable, set that slot option, and in cd_setup()
155 if (helper->props & MMC_PROP_NON_REMOVABLE) { in cd_setup()
156 helper->cd_disabled = true; in cd_setup()
158 device_printf(dev, "Non-removable media\n"); in cd_setup()
163 * If the device has no card-detection, treat it as non-removable. in cd_setup()
166 if (helper->props & MMC_PROP_BROKEN_CD) { in cd_setup()
167 helper->cd_disabled = true; in cd_setup()
169 device_printf(dev, "Broken card-detect\n"); in cd_setup()
174 * If there is no cd-gpios property, then presumably the hardware in cd_setup()
175 * PRESENT_STATE register and interrupts will reflect card state in cd_setup()
181 if (gpio_pin_get_by_ofw_property(dev, node, "cd-gpios", in cd_setup()
182 &helper->cd_pin)) in cd_setup()
185 if (gpio_pin_getcaps(helper->cd_pin, &pincaps) != 0 || in cd_setup()
187 device_printf(dev, "Cannot read card-detect gpio pin; " in cd_setup()
188 "setting card-always-present flag.\n"); in cd_setup()
189 helper->cd_disabled = true; in cd_setup()
195 * we can use it to detect card presence changes. If not, we'll request in cd_setup()
196 * card presence polling instead of using interrupts. in cd_setup()
205 if (helper->cd_handler == NULL) { in cd_setup()
208 "interrupts as no cd_handler is set\n"); in cd_setup()
215 if ((helper->cd_ires = gpio_alloc_intr_resource(dev, &helper->cd_irid, in cd_setup()
216 RF_ACTIVE, helper->cd_pin, GPIO_INTR_EDGE_BOTH)) == NULL) { in cd_setup()
223 if (bus_setup_intr(dev, helper->cd_ires, INTR_TYPE_BIO | INTR_MPSAFE, in cd_setup()
224 NULL, cd_intr, helper, &helper->cd_ihandler) != 0) { in cd_setup()
225 device_printf(dev, "Unable to setup card-detect irq handler\n"); in cd_setup()
226 helper->cd_ihandler = NULL; in cd_setup()
233 * gpio interrupts, setup a timeout task to poll the pin in cd_setup()
235 if (helper->cd_ihandler == NULL) { in cd_setup()
238 cd_mode_str = "interrupts"; in cd_setup()
244 device_get_nameunit(helper->cd_pin->dev), helper->cd_pin->pin, in cd_setup()
257 dev = helper->dev; in wp_setup()
259 if (OF_hasprop(node, "disable-wp")) { in wp_setup()
260 helper->wp_disabled = true; in wp_setup()
266 if (gpio_pin_get_by_ofw_property(dev, node, "wp-gpios", &helper->wp_pin)) in wp_setup()
271 device_get_nameunit(helper->wp_pin->dev), helper->wp_pin->pin); in wp_setup()
286 helper->dev = dev; in mmc_fdt_gpio_setup()
287 helper->cd_handler = handler; in mmc_fdt_gpio_setup()
295 &helper->cd_delayed_task, mstosbt(500), 0, C_PREL(2)); in mmc_fdt_gpio_setup()
306 if (helper->cd_ihandler != NULL) in mmc_fdt_gpio_teardown()
307 bus_teardown_intr(helper->dev, helper->cd_ires, helper->cd_ihandler); in mmc_fdt_gpio_teardown()
308 if (helper->wp_pin != NULL) in mmc_fdt_gpio_teardown()
309 gpio_pin_release(helper->wp_pin); in mmc_fdt_gpio_teardown()
310 if (helper->cd_pin != NULL) in mmc_fdt_gpio_teardown()
311 gpio_pin_release(helper->cd_pin); in mmc_fdt_gpio_teardown()
312 if (helper->cd_ires != NULL) in mmc_fdt_gpio_teardown()
313 bus_release_resource(helper->dev, SYS_RES_IRQ, 0, helper->cd_ires); in mmc_fdt_gpio_teardown()
315 taskqueue_drain_timeout(taskqueue_bus, &helper->cd_delayed_task); in mmc_fdt_gpio_teardown()
323 if (helper->cd_disabled) in mmc_fdt_gpio_get_present()
325 if (helper->cd_pin == NULL) in mmc_fdt_gpio_get_present()
328 gpio_pin_is_active(helper->cd_pin, &pinstate); in mmc_fdt_gpio_get_present()
330 return (pinstate ^ (bool)(helper->props & MMC_PROP_CD_INVERTED)); in mmc_fdt_gpio_get_present()
338 if (helper->wp_disabled) in mmc_fdt_gpio_get_readonly()
341 if (helper->wp_pin == NULL) in mmc_fdt_gpio_get_readonly()
344 gpio_pin_is_active(helper->wp_pin, &pinstate); in mmc_fdt_gpio_get_readonly()
346 return (pinstate ^ (bool)(helper->props & MMC_PROP_WP_INVERTED)); in mmc_fdt_gpio_get_readonly()
359 if (helper->vmmc_supply) { in mmc_fdt_set_power()
360 rv = regulator_status(helper->vmmc_supply, ®_status); in mmc_fdt_set_power()
362 regulator_disable(helper->vmmc_supply); in mmc_fdt_set_power()
364 if (helper->vqmmc_supply) { in mmc_fdt_set_power()
365 rv = regulator_status(helper->vqmmc_supply, ®_status); in mmc_fdt_set_power()
367 regulator_disable(helper->vqmmc_supply); in mmc_fdt_set_power()
369 if (helper->mmc_pwrseq) in mmc_fdt_set_power()
370 MMC_PWRSEQ_SET_POWER(helper->mmc_pwrseq, false); in mmc_fdt_set_power()
373 if (helper->vmmc_supply) { in mmc_fdt_set_power()
374 rv = regulator_status(helper->vmmc_supply, ®_status); in mmc_fdt_set_power()
376 regulator_enable(helper->vmmc_supply); in mmc_fdt_set_power()
378 if (helper->vqmmc_supply) { in mmc_fdt_set_power()
379 rv = regulator_status(helper->vqmmc_supply, ®_status); in mmc_fdt_set_power()
381 regulator_enable(helper->vqmmc_supply); in mmc_fdt_set_power()
383 if (helper->mmc_pwrseq) in mmc_fdt_set_power()
384 MMC_PWRSEQ_SET_POWER(helper->mmc_pwrseq, true); in mmc_fdt_set_power()