Lines Matching full:state

46 static void switch_to_flash(struct async_state *state)  in switch_to_flash()  argument
48 local_irq_save(state->irq_flags); in switch_to_flash()
50 gpio_set_value(state->enet_flash_pin, 0); in switch_to_flash()
52 state->save_ambctl0 = bfin_read_EBIU_AMBCTL0(); in switch_to_flash()
53 state->save_ambctl1 = bfin_read_EBIU_AMBCTL1(); in switch_to_flash()
54 bfin_write_EBIU_AMBCTL0(state->flash_ambctl0); in switch_to_flash()
55 bfin_write_EBIU_AMBCTL1(state->flash_ambctl1); in switch_to_flash()
59 static void switch_back(struct async_state *state) in switch_back() argument
61 bfin_write_EBIU_AMBCTL0(state->save_ambctl0); in switch_back()
62 bfin_write_EBIU_AMBCTL1(state->save_ambctl1); in switch_back()
65 gpio_set_value(state->enet_flash_pin, 1); in switch_back()
67 local_irq_restore(state->irq_flags); in switch_back()
72 struct async_state *state = (struct async_state *)map->map_priv_1; in bfin_flash_read() local
76 switch_to_flash(state); in bfin_flash_read()
80 switch_back(state); in bfin_flash_read()
88 struct async_state *state = (struct async_state *)map->map_priv_1; in bfin_flash_copy_from() local
90 switch_to_flash(state); in bfin_flash_copy_from()
94 switch_back(state); in bfin_flash_copy_from()
99 struct async_state *state = (struct async_state *)map->map_priv_1; in bfin_flash_write() local
104 switch_to_flash(state); in bfin_flash_write()
109 switch_back(state); in bfin_flash_write()
114 struct async_state *state = (struct async_state *)map->map_priv_1; in bfin_flash_copy_to() local
116 switch_to_flash(state); in bfin_flash_copy_to()
121 switch_back(state); in bfin_flash_copy_to()
132 struct async_state *state; in bfin_flash_probe() local
134 state = kzalloc(sizeof(*state), GFP_KERNEL); in bfin_flash_probe()
135 if (!state) in bfin_flash_probe()
138 state->map.name = DRIVER_NAME; in bfin_flash_probe()
139 state->map.read = bfin_flash_read; in bfin_flash_probe()
140 state->map.copy_from = bfin_flash_copy_from; in bfin_flash_probe()
141 state->map.write = bfin_flash_write; in bfin_flash_probe()
142 state->map.copy_to = bfin_flash_copy_to; in bfin_flash_probe()
143 state->map.bankwidth = pdata->width; in bfin_flash_probe()
144 state->map.size = resource_size(memory); in bfin_flash_probe()
145 state->map.virt = (void __iomem *)memory->start; in bfin_flash_probe()
146 state->map.phys = memory->start; in bfin_flash_probe()
147 state->map.map_priv_1 = (unsigned long)state; in bfin_flash_probe()
148 state->enet_flash_pin = platform_get_irq(pdev, 0); in bfin_flash_probe()
149 state->flash_ambctl0 = flash_ambctl->start; in bfin_flash_probe()
150 state->flash_ambctl1 = flash_ambctl->end; in bfin_flash_probe()
152 if (gpio_request(state->enet_flash_pin, DRIVER_NAME)) { in bfin_flash_probe()
153 pr_devinit(KERN_ERR DRIVER_NAME ": Failed to request gpio %d\n", state->enet_flash_pin); in bfin_flash_probe()
154 kfree(state); in bfin_flash_probe()
157 gpio_direction_output(state->enet_flash_pin, 1); in bfin_flash_probe()
159 pr_devinit(KERN_NOTICE DRIVER_NAME ": probing %d-bit flash bus\n", state->map.bankwidth * 8); in bfin_flash_probe()
160 state->mtd = do_map_probe(memory->name, &state->map); in bfin_flash_probe()
161 if (!state->mtd) { in bfin_flash_probe()
162 gpio_free(state->enet_flash_pin); in bfin_flash_probe()
163 kfree(state); in bfin_flash_probe()
167 mtd_device_parse_register(state->mtd, part_probe_types, 0, in bfin_flash_probe()
170 platform_set_drvdata(pdev, state); in bfin_flash_probe()
177 struct async_state *state = platform_get_drvdata(pdev); in bfin_flash_remove() local
178 gpio_free(state->enet_flash_pin); in bfin_flash_remove()
179 mtd_device_unregister(state->mtd); in bfin_flash_remove()
180 map_destroy(state->mtd); in bfin_flash_remove()
181 kfree(state); in bfin_flash_remove()