Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

wan: ixp4xx_hss: prepare compile testing

The ixp4xx_hss driver needs the platform data definition and the
system clock rate to be compiled. Move both into a new platform_data
header file.

This is a prerequisite for compile testing, but turning on compile
testing requires further patches to isolate the SoC headers.

Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Jakub Kicinski <kuba@kernel.org>

authored by

Arnd Bergmann and committed by
Jakub Kicinski
c74f16b6 504c28c8

+43 -25
+4
arch/arm/mach-ixp4xx/goramo_mlr.c
··· 11 11 #include <linux/irq.h> 12 12 #include <linux/kernel.h> 13 13 #include <linux/pci.h> 14 + #include <linux/platform_data/wan_ixp4xx_hss.h> 14 15 #include <linux/serial_8250.h> 15 16 #include <asm/mach-types.h> 16 17 #include <asm/mach/arch.h> ··· 405 404 device_tab[devices++] = &device_hss_tab[0]; /* max index 4 */ 406 405 if (hw_bits & CFG_HW_HAS_HSS1) 407 406 device_tab[devices++] = &device_hss_tab[1]; /* max index 5 */ 407 + 408 + hss_plat[0].timer_freq = ixp4xx_timer_freq; 409 + hss_plat[1].timer_freq = ixp4xx_timer_freq; 408 410 409 411 gpio_request(GPIO_SCL, "SCL/clock"); 410 412 gpio_request(GPIO_SDA, "SDA/data");
-9
arch/arm/mach-ixp4xx/include/mach/platform.h
··· 104 104 u8 hwaddr[6]; 105 105 }; 106 106 107 - /* Information about built-in HSS (synchronous serial) interfaces */ 108 - struct hss_plat_info { 109 - int (*set_clock)(int port, unsigned int clock_type); 110 - int (*open)(int port, void *pdev, 111 - void (*set_carrier_cb)(void *pdev, int carrier)); 112 - void (*close)(int port, void *pdev); 113 - u8 txreadyq; 114 - }; 115 - 116 107 /* 117 108 * Frequency of clock used for primary clocksource 118 109 */
+2 -1
drivers/net/wan/Kconfig
··· 315 315 316 316 config IXP4XX_HSS 317 317 tristate "Intel IXP4xx HSS (synchronous serial port) support" 318 - depends on HDLC && ARM && ARCH_IXP4XX && IXP4XX_NPE && IXP4XX_QMGR 318 + depends on HDLC && IXP4XX_NPE && IXP4XX_QMGR 319 + depends on ARCH_IXP4XX 319 320 help 320 321 Say Y here if you want to use built-in HSS ports 321 322 on IXP4xx processor.
+20 -15
drivers/net/wan/ixp4xx_hss.c
··· 17 17 #include <linux/io.h> 18 18 #include <linux/kernel.h> 19 19 #include <linux/platform_device.h> 20 + #include <linux/platform_data/wan_ixp4xx_hss.h> 20 21 #include <linux/poll.h> 21 22 #include <linux/slab.h> 22 23 #include <linux/soc/ixp4xx/npe.h> ··· 1183 1182 } 1184 1183 } 1185 1184 1186 - static u32 check_clock(u32 rate, u32 a, u32 b, u32 c, 1185 + static u32 check_clock(u32 timer_freq, u32 rate, u32 a, u32 b, u32 c, 1187 1186 u32 *best, u32 *best_diff, u32 *reg) 1188 1187 { 1189 1188 /* a is 10-bit, b is 10-bit, c is 12-bit */ 1190 1189 u64 new_rate; 1191 1190 u32 new_diff; 1192 1191 1193 - new_rate = ixp4xx_timer_freq * (u64)(c + 1); 1192 + new_rate = timer_freq * (u64)(c + 1); 1194 1193 do_div(new_rate, a * (c + 1) + b + 1); 1195 1194 new_diff = abs((u32)new_rate - rate); 1196 1195 ··· 1202 1201 return new_diff; 1203 1202 } 1204 1203 1205 - static void find_best_clock(u32 rate, u32 *best, u32 *reg) 1204 + static void find_best_clock(u32 timer_freq, u32 rate, u32 *best, u32 *reg) 1206 1205 { 1207 1206 u32 a, b, diff = 0xFFFFFFFF; 1208 1207 1209 - a = ixp4xx_timer_freq / rate; 1208 + a = timer_freq / rate; 1210 1209 1211 1210 if (a > 0x3FF) { /* 10-bit value - we can go as slow as ca. 65 kb/s */ 1212 - check_clock(rate, 0x3FF, 1, 1, best, &diff, reg); 1211 + check_clock(timer_freq, rate, 0x3FF, 1, 1, best, &diff, reg); 1213 1212 return; 1214 1213 } 1215 1214 if (a == 0) { /* > 66.666 MHz */ 1216 1215 a = 1; /* minimum divider is 1 (a = 0, b = 1, c = 1) */ 1217 - rate = ixp4xx_timer_freq; 1216 + rate = timer_freq; 1218 1217 } 1219 1218 1220 - if (rate * a == ixp4xx_timer_freq) { /* don't divide by 0 later */ 1221 - check_clock(rate, a - 1, 1, 1, best, &diff, reg); 1219 + if (rate * a == timer_freq) { /* don't divide by 0 later */ 1220 + check_clock(timer_freq, rate, a - 1, 1, 1, best, &diff, reg); 1222 1221 return; 1223 1222 } 1224 1223 1225 1224 for (b = 0; b < 0x400; b++) { 1226 1225 u64 c = (b + 1) * (u64)rate; 1227 - do_div(c, ixp4xx_timer_freq - rate * a); 1226 + do_div(c, timer_freq - rate * a); 1228 1227 c--; 1229 1228 if (c >= 0xFFF) { /* 12-bit - no need to check more 'b's */ 1230 1229 if (b == 0 && /* also try a bit higher rate */ 1231 - !check_clock(rate, a - 1, 1, 1, best, &diff, reg)) 1230 + !check_clock(timer_freq, rate, a - 1, 1, 1, best, 1231 + &diff, reg)) 1232 1232 return; 1233 - check_clock(rate, a, b, 0xFFF, best, &diff, reg); 1233 + check_clock(timer_freq, rate, a, b, 0xFFF, best, 1234 + &diff, reg); 1234 1235 return; 1235 1236 } 1236 - if (!check_clock(rate, a, b, c, best, &diff, reg)) 1237 + if (!check_clock(timer_freq, rate, a, b, c, best, &diff, reg)) 1237 1238 return; 1238 - if (!check_clock(rate, a, b, c + 1, best, &diff, reg)) 1239 + if (!check_clock(timer_freq, rate, a, b, c + 1, best, &diff, 1240 + reg)) 1239 1241 return; 1240 1242 } 1241 1243 } ··· 1289 1285 1290 1286 port->clock_type = clk; /* Update settings */ 1291 1287 if (clk == CLOCK_INT) 1292 - find_best_clock(new_line.clock_rate, &port->clock_rate, 1293 - &port->clock_reg); 1288 + find_best_clock(port->plat->timer_freq, 1289 + new_line.clock_rate, 1290 + &port->clock_rate, &port->clock_reg); 1294 1291 else { 1295 1292 port->clock_rate = 0; 1296 1293 port->clock_reg = CLK42X_SPEED_2048KHZ;
+17
include/linux/platform_data/wan_ixp4xx_hss.h
··· 1 + /* SPDX-License-Identifier: GPL-2.0 */ 2 + #ifndef __PLATFORM_DATA_WAN_IXP4XX_HSS_H 3 + #define __PLATFORM_DATA_WAN_IXP4XX_HSS_H 4 + 5 + #include <linux/types.h> 6 + 7 + /* Information about built-in HSS (synchronous serial) interfaces */ 8 + struct hss_plat_info { 9 + int (*set_clock)(int port, unsigned int clock_type); 10 + int (*open)(int port, void *pdev, 11 + void (*set_carrier_cb)(void *pdev, int carrier)); 12 + void (*close)(int port, void *pdev); 13 + u8 txreadyq; 14 + u32 timer_freq; 15 + }; 16 + 17 + #endif