aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJohannes Berg <johannes@sipsolutions.net>2007-08-22 17:01:31 -0400
committerLinus Torvalds <torvalds@woody.linux-foundation.org>2007-08-22 22:52:45 -0400
commit0d5e74fc7f44b1cdcd793496877c67a2a7a32a1e (patch)
tree2ee7dfb35753344239ffab12271a192df7055020
parent4088af39cc052eeb6c4568a706c403ce151f5bd2 (diff)
remove dead code in via-pmu68k
When suspend is ever implemented for pmu68k it really should follow the generic pm_ops concept and not mirror the platform-specific /dev/pmu device with ioctls on it. Hence, this patch removes the unused code there; should the implementers need it they can look at via-pmu.c and/or the history of the file. Signed-off-by: Johannes Berg <johannes@sipsolutions.net> Signed-off-by: Geert Uytterhoeven <geert@linux-m68k.org> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
-rw-r--r--drivers/macintosh/via-pmu68k.c240
1 files changed, 0 insertions, 240 deletions
diff --git a/drivers/macintosh/via-pmu68k.c b/drivers/macintosh/via-pmu68k.c
index dfdf11c1eec4..e2f84da09e7c 100644
--- a/drivers/macintosh/via-pmu68k.c
+++ b/drivers/macintosh/via-pmu68k.c
@@ -818,243 +818,3 @@ pmu_present(void)
818{ 818{
819 return (pmu_kind != PMU_UNKNOWN); 819 return (pmu_kind != PMU_UNKNOWN);
820} 820}
821
822#if 0 /* needs some work for 68K */
823
824/*
825 * This struct is used to store config register values for
826 * PCI devices which may get powered off when we sleep.
827 */
828static struct pci_save {
829 u16 command;
830 u16 cache_lat;
831 u16 intr;
832} *pbook_pci_saves;
833static int n_pbook_pci_saves;
834
835static inline void
836pbook_pci_save(void)
837{
838 int npci;
839 struct pci_dev *pd = NULL;
840 struct pci_save *ps;
841
842 npci = 0;
843 while ((pd = pci_get_device(PCI_ANY_ID, PCI_ANY_ID, pd)) != NULL)
844 ++npci;
845 n_pbook_pci_saves = npci;
846 if (npci == 0)
847 return;
848 ps = kmalloc(npci * sizeof(*ps), GFP_KERNEL);
849 pbook_pci_saves = ps;
850 if (ps == NULL)
851 return;
852
853 pd = NULL;
854 while ((pd = pci_get_device(PCI_ANY_ID, PCI_ANY_ID, pd)) != NULL) {
855 pci_read_config_word(pd, PCI_COMMAND, &ps->command);
856 pci_read_config_word(pd, PCI_CACHE_LINE_SIZE, &ps->cache_lat);
857 pci_read_config_word(pd, PCI_INTERRUPT_LINE, &ps->intr);
858 ++ps;
859 --npci;
860 }
861}
862
863static inline void
864pbook_pci_restore(void)
865{
866 u16 cmd;
867 struct pci_save *ps = pbook_pci_saves;
868 struct pci_dev *pd = NULL;
869 int j;
870
871 while ((pd = pci_get_device(PCI_ANY_ID, PCI_ANY_ID, pd)) != NULL) {
872 if (ps->command == 0)
873 continue;
874 pci_read_config_word(pd, PCI_COMMAND, &cmd);
875 if ((ps->command & ~cmd) == 0)
876 continue;
877 switch (pd->hdr_type) {
878 case PCI_HEADER_TYPE_NORMAL:
879 for (j = 0; j < 6; ++j)
880 pci_write_config_dword(pd,
881 PCI_BASE_ADDRESS_0 + j*4,
882 pd->resource[j].start);
883 pci_write_config_dword(pd, PCI_ROM_ADDRESS,
884 pd->resource[PCI_ROM_RESOURCE].start);
885 pci_write_config_word(pd, PCI_CACHE_LINE_SIZE,
886 ps->cache_lat);
887 pci_write_config_word(pd, PCI_INTERRUPT_LINE,
888 ps->intr);
889 pci_write_config_word(pd, PCI_COMMAND, ps->command);
890 break;
891 /* other header types not restored at present */
892 }
893 }
894}
895
896/*
897 * Put the powerbook to sleep.
898 */
899#define IRQ_ENABLE ((unsigned int *)0xf3000024)
900#define MEM_CTRL ((unsigned int *)0xf8000070)
901
902int powerbook_sleep(void)
903{
904 int ret, i, x;
905 static int save_backlight;
906 static unsigned int save_irqen;
907 unsigned long msr;
908 unsigned int hid0;
909 unsigned long p, wait;
910 struct adb_request sleep_req;
911
912 /* Notify device drivers */
913 ret = blocking_notifier_call_chain(&sleep_notifier_list,
914 PBOOK_SLEEP, NULL);
915 if (ret & NOTIFY_STOP_MASK)
916 return -EBUSY;
917
918 /* Sync the disks. */
919 /* XXX It would be nice to have some way to ensure that
920 * nobody is dirtying any new buffers while we wait. */
921 sys_sync();
922
923 /* Turn off the display backlight */
924 save_backlight = backlight_enabled;
925 if (save_backlight)
926 pmu_enable_backlight(0);
927
928 /* Give the disks a little time to actually finish writing */
929 for (wait = jiffies + (HZ/4); time_before(jiffies, wait); )
930 mb();
931
932 /* Disable all interrupts except pmu */
933 save_irqen = in_le32(IRQ_ENABLE);
934 for (i = 0; i < 32; ++i)
935 if (i != vias->intrs[0].line && (save_irqen & (1 << i)))
936 disable_irq(i);
937 asm volatile("mtdec %0" : : "r" (0x7fffffff));
938
939 /* Save the state of PCI config space for some slots */
940 pbook_pci_save();
941
942 /* Set the memory controller to keep the memory refreshed
943 while we're asleep */
944 for (i = 0x403f; i >= 0x4000; --i) {
945 out_be32(MEM_CTRL, i);
946 do {
947 x = (in_be32(MEM_CTRL) >> 16) & 0x3ff;
948 } while (x == 0);
949 if (x >= 0x100)
950 break;
951 }
952
953 /* Ask the PMU to put us to sleep */
954 pmu_request(&sleep_req, NULL, 5, PMU_SLEEP, 'M', 'A', 'T', 'T');
955 while (!sleep_req.complete)
956 mb();
957 /* displacement-flush the L2 cache - necessary? */
958 for (p = KERNELBASE; p < KERNELBASE + 0x100000; p += 0x1000)
959 i = *(volatile int *)p;
960 asleep = 1;
961
962 /* Put the CPU into sleep mode */
963 asm volatile("mfspr %0,1008" : "=r" (hid0) :);
964 hid0 = (hid0 & ~(HID0_NAP | HID0_DOZE)) | HID0_SLEEP;
965 asm volatile("mtspr 1008,%0" : : "r" (hid0));
966 local_save_flags(msr);
967 msr |= MSR_POW | MSR_EE;
968 local_irq_restore(msr);
969 udelay(10);
970
971 /* OK, we're awake again, start restoring things */
972 out_be32(MEM_CTRL, 0x3f);
973 pbook_pci_restore();
974
975 /* wait for the PMU interrupt sequence to complete */
976 while (asleep)
977 mb();
978
979 /* reenable interrupts */
980 for (i = 0; i < 32; ++i)
981 if (i != vias->intrs[0].line && (save_irqen & (1 << i)))
982 enable_irq(i);
983
984 /* Notify drivers */
985 blocking_notifier_call_chain(&sleep_notifier_list, PBOOK_WAKE, NULL);
986
987 /* reenable ADB autopoll */
988 pmu_adb_autopoll(adb_dev_map);
989
990 /* Turn on the screen backlight, if it was on before */
991 if (save_backlight)
992 pmu_enable_backlight(1);
993
994 /* Wait for the hard disk to spin up */
995
996 return 0;
997}
998
999/*
1000 * Support for /dev/pmu device
1001 */
1002static int pmu_open(struct inode *inode, struct file *file)
1003{
1004 return 0;
1005}
1006
1007static ssize_t pmu_read(struct file *file, char *buf,
1008 size_t count, loff_t *ppos)
1009{
1010 return 0;
1011}
1012
1013static ssize_t pmu_write(struct file *file, const char *buf,
1014 size_t count, loff_t *ppos)
1015{
1016 return 0;
1017}
1018
1019static int pmu_ioctl(struct inode * inode, struct file *filp,
1020 u_int cmd, u_long arg)
1021{
1022 int error;
1023 __u32 value;
1024
1025 switch (cmd) {
1026 case PMU_IOC_SLEEP:
1027 return -ENOSYS;
1028 case PMU_IOC_GET_BACKLIGHT:
1029 return put_user(backlight_level, (__u32 *)arg);
1030 case PMU_IOC_SET_BACKLIGHT:
1031 error = get_user(value, (__u32 *)arg);
1032 if (!error)
1033 pmu_set_brightness(value);
1034 return error;
1035 case PMU_IOC_GET_MODEL:
1036 return put_user(pmu_kind, (__u32 *)arg);
1037 }
1038 return -EINVAL;
1039}
1040
1041static const struct file_operations pmu_device_fops = {
1042 .read = pmu_read,
1043 .write = pmu_write,
1044 .ioctl = pmu_ioctl,
1045 .open = pmu_open,
1046};
1047
1048static struct miscdevice pmu_device = {
1049 PMU_MINOR, "pmu", &pmu_device_fops
1050};
1051
1052void pmu_device_init(void)
1053{
1054 if (!via)
1055 return;
1056 if (misc_register(&pmu_device) < 0)
1057 printk(KERN_ERR "via-pmu68k: cannot register misc device.\n");
1058}
1059#endif /* CONFIG_PMAC_PBOOK */
1060