1 // SPDX-License-Identifier: GPL-2.0-only
3 * Thomas Horsten <thh@lasat.com>
4 * Copyright (C) 2000 LASAT Networks A/S.
6 * Routines specific to the LASAT boards
8 #include <linux/types.h>
9 #include <asm/lasat/lasat.h>
11 #include <linux/sysctl.h>
12 #include <linux/stddef.h>
13 #include <linux/init.h>
15 #include <linux/ctype.h>
16 #include <linux/string.h>
17 #include <linux/net.h>
18 #include <linux/inet.h>
19 #include <linux/uaccess.h>
28 /* And the same for proc */
29 int proc_dolasatstring(struct ctl_table *table, int write,
30 void *buffer, size_t *lenp, loff_t *ppos)
34 r = proc_dostring(table, write, buffer, lenp, ppos);
38 lasat_write_eeprom_info();
46 /* proc function to read/write RealTime Clock */
47 int proc_dolasatrtc(struct ctl_table *table, int write,
48 void *buffer, size_t *lenp, loff_t *ppos)
54 read_persistent_clock64(&ts);
56 /* check for time < 0 and set to 0 */
60 r = proc_dointvec(table, write, buffer, lenp, ppos);
66 * Due to the RTC hardware limitation, we can not actually
67 * use the full 64-bit range here.
72 update_persistent_clock64(ts);
80 int proc_lasat_ip(struct ctl_table *table, int write,
81 void *buffer, size_t *lenp, loff_t *ppos)
88 if (!table->data || !table->maxlen || !*lenp ||
100 if (c == 0 || c == '\n')
104 if (len >= sizeof(ipbuf)-1)
105 len = sizeof(ipbuf) - 1;
106 memcpy(ipbuf, buffer, len);
109 /* Now see if we can convert it to a valid IP */
111 *(unsigned int *)(table->data) = ip;
112 lasat_write_eeprom_info();
114 ip = *(unsigned int *)(table->data);
115 sprintf(ipbuf, "%d.%d.%d.%d",
124 memcpy(buffer, ipbuf, len);
126 *((char *)buffer + len) = '\n';
137 int proc_lasat_prid(struct ctl_table *table, int write,
138 void *buffer, size_t *lenp, loff_t *ppos)
142 r = proc_dointvec(table, write, buffer, lenp, ppos);
146 lasat_board_info.li_eeprom_info.prid =
147 lasat_board_info.li_prid;
148 lasat_write_eeprom_info();
149 lasat_init_board_info();
154 extern int lasat_boot_to_service;
156 static struct ctl_table lasat_table[] = {
158 .procname = "cpu-hz",
159 .data = &lasat_board_info.li_cpu_hz,
160 .maxlen = sizeof(int),
162 .proc_handler = proc_dointvec,
165 .procname = "bus-hz",
166 .data = &lasat_board_info.li_bus_hz,
167 .maxlen = sizeof(int),
169 .proc_handler = proc_dointvec,
173 .data = &lasat_board_info.li_bmid,
174 .maxlen = sizeof(int),
176 .proc_handler = proc_dointvec,
180 .data = &lasat_board_info.li_prid,
181 .maxlen = sizeof(int),
183 .proc_handler = proc_lasat_prid,
187 .procname = "ipaddr",
188 .data = &lasat_board_info.li_eeprom_info.ipaddr,
189 .maxlen = sizeof(int),
191 .proc_handler = proc_lasat_ip,
194 .procname = "netmask",
195 .data = &lasat_board_info.li_eeprom_info.netmask,
196 .maxlen = sizeof(int),
198 .proc_handler = proc_lasat_ip,
202 .procname = "passwd_hash",
203 .data = &lasat_board_info.li_eeprom_info.passwd_hash,
205 sizeof(lasat_board_info.li_eeprom_info.passwd_hash),
207 .proc_handler = proc_dolasatstring,
210 .procname = "boot-service",
211 .data = &lasat_boot_to_service,
212 .maxlen = sizeof(int),
214 .proc_handler = proc_dointvec,
220 .maxlen = sizeof(int),
222 .proc_handler = proc_dolasatrtc,
226 .procname = "namestr",
227 .data = &lasat_board_info.li_namestr,
228 .maxlen = sizeof(lasat_board_info.li_namestr),
230 .proc_handler = proc_dostring,
233 .procname = "typestr",
234 .data = &lasat_board_info.li_typestr,
235 .maxlen = sizeof(lasat_board_info.li_typestr),
237 .proc_handler = proc_dostring,
242 static struct ctl_table lasat_root_table[] = {
251 static int __init lasat_register_sysctl(void)
253 struct ctl_table_header *lasat_table_header;
256 register_sysctl_table(lasat_root_table);
257 if (!lasat_table_header) {
258 printk(KERN_ERR "Unable to register LASAT sysctl\n");
265 arch_initcall(lasat_register_sysctl);