Re: [RFC v3 02/24] m68k/atari: Move Atari-specific code out of drivers/char/nvram.c

2015-07-01 Thread Finn Thain

On Mon, 29 Jun 2015, Geert Uytterhoeven wrote:

 Hi Finn,
 
 On Sun, Jun 28, 2015 at 3:42 AM, Finn Thain fth...@telegraphics.com.au 
 wrote:
  Change the vmode calculation from logical OR to bitwise OR, since it 
  is obviously wrong.
 
 Ideally, that should be a separate patch we can put on the fast track.

If you will fast track a portion of this patch series, that's great. I'll 
send a separate patch. (However, IMHO, that portion which would ideally be 
fast tracked is a matter of opinion.)

-- 

 
 Gr{oetje,eeting}s,
 
 Geert
 
___
Linuxppc-dev mailing list
Linuxppc-dev@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/linuxppc-dev

Re: [RFC v3 02/24] m68k/atari: Move Atari-specific code out of drivers/char/nvram.c

2015-06-29 Thread Geert Uytterhoeven
Hi Finn,

On Sun, Jun 28, 2015 at 3:42 AM, Finn Thain fth...@telegraphics.com.au wrote:
 Change the vmode calculation from logical OR to bitwise OR, since it is
 obviously wrong.

Ideally, that should be a separate patch we can put on the fast track.

Gr{oetje,eeting}s,

Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- ge...@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say programmer or something like that.
-- Linus Torvalds
___
Linuxppc-dev mailing list
Linuxppc-dev@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/linuxppc-dev

[RFC v3 02/24] m68k/atari: Move Atari-specific code out of drivers/char/nvram.c

2015-06-27 Thread Finn Thain
Move the m68k-specific code elsewhere to make the driver generic.

Change the vmode calculation from logical OR to bitwise OR, since it is
obviously wrong.

Signed-off-by: Finn Thain fth...@telegraphics.com.au

---

BTW, I didn't change the SCSI ID location in NVRAM. This code says 16
whereas atari_scsi says 14. Which one is correct?

---
 arch/m68k/atari/Makefile |2 
 arch/m68k/atari/nvram.c  |  255 ++
 drivers/char/nvram.c |  280 +--
 3 files changed, 292 insertions(+), 245 deletions(-)

Index: linux/arch/m68k/atari/nvram.c
===
--- /dev/null   1970-01-01 00:00:00.0 +
+++ linux/arch/m68k/atari/nvram.c   2015-06-28 11:41:29.0 +1000
@@ -0,0 +1,255 @@
+/*
+ * CMOS/NV-RAM driver for Atari. Adapted from drivers/char/nvram.c.
+ * Copyright (C) 1997 Roman Hodek roman.ho...@informatik.uni-erlangen.de
+ * idea by and with help from Richard Jelinek r...@suse.de
+ * Portions copyright (c) 2001,2002 Sun Microsystems (thoc...@sun.com)
+ * Further contributions from Cesar Barros, Erik Gilling, Tim Hockin and
+ * Wim Van Sebroeck.
+ */
+
+#include linux/errno.h
+#include linux/init.h
+#include linux/mc146818rtc.h
+#include linux/module.h
+#include linux/nvram.h
+#include linux/proc_fs.h
+#include linux/seq_file.h
+#include linux/spinlock.h
+#include linux/types.h
+#include asm/atarihw.h
+#include asm/atariints.h
+
+#define NVRAM_BYTES50
+
+/* It is worth noting that these functions all access bytes of general
+ * purpose memory in the NVRAM - that is to say, they all add the
+ * NVRAM_FIRST_BYTE offset. Pass them offsets into NVRAM as if you did not
+ * know about the RTC cruft.
+ */
+
+/* Note that *all* calls to CMOS_READ and CMOS_WRITE must be done with
+ * rtc_lock held. Due to the index-port/data-port design of the RTC, we
+ * don't want two different things trying to get to it at once. (e.g. the
+ * periodic 11 min sync from kernel/time/ntp.c vs. this driver.)
+ */
+
+unsigned char __nvram_read_byte(int i)
+{
+   return CMOS_READ(NVRAM_FIRST_BYTE + i);
+}
+
+unsigned char nvram_read_byte(int i)
+{
+   unsigned long flags;
+   unsigned char c;
+
+   spin_lock_irqsave(rtc_lock, flags);
+   c = __nvram_read_byte(i);
+   spin_unlock_irqrestore(rtc_lock, flags);
+   return c;
+}
+EXPORT_SYMBOL(nvram_read_byte);
+
+/* This races nicely with trying to read with checksum checking */
+void __nvram_write_byte(unsigned char c, int i)
+{
+   CMOS_WRITE(c, NVRAM_FIRST_BYTE + i);
+}
+
+void nvram_write_byte(unsigned char c, int i)
+{
+   unsigned long flags;
+
+   spin_lock_irqsave(rtc_lock, flags);
+   __nvram_write_byte(c, i);
+   spin_unlock_irqrestore(rtc_lock, flags);
+}
+
+/* On Ataris, the checksum is over all bytes except the checksum bytes
+ * themselves; these are at the very end.
+ */
+#define ATARI_CKS_RANGE_START  0
+#define ATARI_CKS_RANGE_END47
+#define ATARI_CKS_LOC  48
+
+int __nvram_check_checksum(void)
+{
+   int i;
+   unsigned char sum = 0;
+
+   for (i = ATARI_CKS_RANGE_START; i = ATARI_CKS_RANGE_END; ++i)
+   sum += __nvram_read_byte(i);
+   return (__nvram_read_byte(ATARI_CKS_LOC) == (~sum  0xff)) 
+  (__nvram_read_byte(ATARI_CKS_LOC + 1) == (sum  0xff));
+}
+
+int nvram_check_checksum(void)
+{
+   unsigned long flags;
+   int rv;
+
+   spin_lock_irqsave(rtc_lock, flags);
+   rv = __nvram_check_checksum();
+   spin_unlock_irqrestore(rtc_lock, flags);
+   return rv;
+}
+EXPORT_SYMBOL(nvram_check_checksum);
+
+static void __nvram_set_checksum(void)
+{
+   int i;
+   unsigned char sum = 0;
+
+   for (i = ATARI_CKS_RANGE_START; i = ATARI_CKS_RANGE_END; ++i)
+   sum += __nvram_read_byte(i);
+   __nvram_write_byte(~sum, ATARI_CKS_LOC);
+   __nvram_write_byte(sum, ATARI_CKS_LOC + 1);
+}
+
+#ifdef CONFIG_PROC_FS
+static struct {
+   unsigned char val;
+   char *name;
+} boot_prefs[] = {
+   { 0x80, TOS },
+   { 0x40, ASV },
+   { 0x20, NetBSD (?) },
+   { 0x10, Linux },
+   { 0x00, unspecified },
+};
+
+static char *languages[] = {
+   English (US),
+   German,
+   French,
+   English (UK),
+   Spanish,
+   Italian,
+   6 (undefined),
+   Swiss (French),
+   Swiss (German),
+};
+
+static char *dateformat[] = {
+   MM%cDD%cYY,
+   DD%cMM%cYY,
+   YY%cMM%cDD,
+   YY%cDD%cMM,
+   4 (undefined),
+   5 (undefined),
+   6 (undefined),
+   7 (undefined),
+};
+
+static char *colors[] = {
+   2, 4, 16, 256, 65536, ??, ??, ??
+};
+
+static void atari_nvram_proc_read(unsigned char *nvram, struct seq_file *seq,
+  void *offset)
+{
+   int checksum;
+   int i;
+   unsigned vmode;
+
+   spin_lock_irq(rtc_lock);
+   checksum =