16 #include <linux/kernel.h>
17 #include <linux/device.h>
27 #define OFFS_CON (0x00)
28 #define OFFS_DAT (0x04)
29 #define OFFS_UP (0x08)
42 u32 gps_gpcon = chip->pm_save[0];
43 u32 gps_gpdat = chip->pm_save[1];
51 gpcon = old_gpcon | gps_gpcon;
59 S3C_PMDBG(
"%s: CON %08x => %08x, DAT %08x => %08x\n",
60 chip->
chip.label, old_gpcon, gps_gpcon, old_gpdat, gps_gpdat);
64 .save = samsung_gpio_pm_1bit_save,
65 .resume = samsung_gpio_pm_1bit_resume,
78 static inline int is_sfn(
unsigned long con)
85 static inline int is_in(
unsigned long con)
92 static inline int is_out(
unsigned long con)
129 u32 gps_gpcon = chip->pm_save[0];
130 u32 gps_gpdat = chip->pm_save[1];
132 u32 change_mask = 0x0;
143 for (nr = 0, mask = 0x03; nr < 32; nr += 2, mask <<= 2) {
144 old = (old_gpcon &
mask) >> nr;
145 new = (gps_gpcon &
mask) >> nr;
154 if (is_sfn(old) && is_sfn(
new))
159 if (is_in(old) && is_out(
new))
164 if (is_sfn(old) && is_out(
new))
176 gpcon = old_gpcon & ~change_mask;
177 gpcon |= gps_gpcon & change_mask;
186 S3C_PMDBG(
"%s: CON %08x => %08x, DAT %08x => %08x\n",
187 chip->
chip.label, old_gpcon, gps_gpcon, old_gpdat, gps_gpdat);
191 .save = samsung_gpio_pm_2bit_save,
192 .resume = samsung_gpio_pm_2bit_resume,
195 #if defined(CONFIG_ARCH_S3C64XX) || defined(CONFIG_PLAT_S5P)
202 if (chip->
chip.ngpio > 8)
206 static u32 samsung_gpio_pm_4bit_mask(
u32 old_gpcon,
u32 gps_gpcon)
209 u32 change_mask = 0x0;
212 for (nr = 0, mask = 0x0f; nr < 16; nr += 4, mask <<= 4) {
213 old = (old_gpcon &
mask) >> nr;
214 new = (gps_gpcon &
mask) >> nr;
223 if (is_sfn(old) && is_sfn(
new))
228 if (is_in(old) && is_out(
new))
233 if (is_sfn(old) && is_out(
new))
249 u32 gps_gpcon = chip->pm_save[index + 1];
252 mask = samsung_gpio_pm_4bit_mask(old_gpcon, gps_gpcon);
254 gpcon = old_gpcon & ~mask;
255 gpcon |= gps_gpcon &
mask;
265 u32 gps_gpdat = chip->pm_save[2];
272 samsung_gpio_pm_4bit_con(chip, 0);
273 if (chip->
chip.ngpio > 8) {
275 samsung_gpio_pm_4bit_con(chip, -1);
282 if (chip->
chip.ngpio > 8)
288 if (chip->
chip.ngpio > 8) {
289 S3C_PMDBG(
"%s: CON4 %08x,%08x => %08x,%08x, DAT %08x => %08x\n",
290 chip->
chip.label, old_gpcon[0], old_gpcon[1],
293 old_gpdat, gps_gpdat);
295 S3C_PMDBG(
"%s: CON4 %08x => %08x, DAT %08x => %08x\n",
296 chip->
chip.label, old_gpcon[1],
298 old_gpdat, gps_gpdat);
302 .save = samsung_gpio_pm_4bit_save,
303 .resume = samsung_gpio_pm_4bit_resume,
316 S3C_PMDBG(
"%s: no pm for %s\n", __func__, ourchip->
chip.label);
330 unsigned int gpio_nr;
333 ourchip = samsung_gpiolib_getchip(gpio_nr);
339 samsung_pm_save_gpio(ourchip);
341 S3C_PMDBG(
"%s: save %08x,%08x,%08x,%08x\n",
346 ourchip->pm_save[3]);
348 gpio_nr += ourchip->
chip.ngpio;
349 gpio_nr += CONFIG_S3C_GPIO_SPACE;
362 S3C_PMDBG(
"%s: no pm for %s\n", __func__, ourchip->
chip.label);
370 unsigned int gpio_nr;
373 ourchip = samsung_gpiolib_getchip(gpio_nr);
379 samsung_pm_resume_gpio(ourchip);
381 gpio_nr += ourchip->
chip.ngpio;
382 gpio_nr += CONFIG_S3C_GPIO_SPACE;