28c28
< __FBSDID("$FreeBSD: head/sys/powerpc/mpc85xx/mpc85xx.c 257178 2013-10-26 18:18:14Z nwhitehorn $");
---
> __FBSDID("$FreeBSD: head/sys/powerpc/mpc85xx/mpc85xx.c 291008 2015-11-18 01:54:19Z jhibbits $");
29a30
> #include "opt_platform.h"
47a49
>
72a75
> int law_max;
75,79c78,95
< if (ver == SVR_MPC8555E || ver == SVR_MPC8555)
< return (8);
< if (ver == SVR_MPC8548E || ver == SVR_MPC8548 ||
< ver == SVR_MPC8533E || ver == SVR_MPC8533)
< return (10);
---
> switch (ver) {
> case SVR_MPC8555:
> case SVR_MPC8555E:
> law_max = 8;
> break;
> case SVR_MPC8533:
> case SVR_MPC8533E:
> case SVR_MPC8548:
> case SVR_MPC8548E:
> law_max = 10;
> break;
> case SVR_P5020:
> case SVR_P5020E:
> law_max = 32;
> break;
> default:
> law_max = 8;
> }
81c97
< return (12);
---
> return (law_max);
83a100,151
> static inline void
> law_write(uint32_t n, uint64_t bar, uint32_t sr)
> {
> #if defined(QORIQ_DPAA)
> ccsr_write4(OCP85XX_LAWBARH(n), bar >> 32);
> ccsr_write4(OCP85XX_LAWBARL(n), bar);
> #else
> ccsr_write4(OCP85XX_LAWBAR(n), bar >> 12);
> #endif
> ccsr_write4(OCP85XX_LAWSR(n), sr);
>
> /*
> * The last write to LAWAR should be followed by a read
> * of LAWAR before any device try to use any of windows.
> * What more the read of LAWAR should be followed by isync
> * instruction.
> */
>
> ccsr_read4(OCP85XX_LAWSR(n));
> isync();
> }
>
> static inline void
> law_read(uint32_t n, uint64_t *bar, uint32_t *sr)
> {
> #if defined(QORIQ_DPAA)
> *bar = (uint64_t)ccsr_read4(OCP85XX_LAWBARH(n)) << 32 |
> ccsr_read4(OCP85XX_LAWBARL(n));
> #else
> *bar = (uint64_t)ccsr_read4(OCP85XX_LAWBAR(n)) << 12;
> #endif
> *sr = ccsr_read4(OCP85XX_LAWSR(n));
> }
>
> static int
> law_find_free(void)
> {
> uint32_t i,sr;
> uint64_t bar;
> int law_max;
>
> law_max = law_getmax();
> /* Find free LAW */
> for (i = 0; i < law_max; i++) {
> law_read(i, &bar, &sr);
> if ((sr & 0x80000000) == 0)
> break;
> }
>
> return (i);
> }
>
85d152
< #define _LAW_BAR(addr) (addr >> 12)
88c155
< law_enable(int trgt, u_long addr, u_long size)
---
> law_enable(int trgt, uint64_t bar, uint32_t size)
90c157,158
< uint32_t bar, sr;
---
> uint64_t bar_tmp;
> uint32_t sr, sr_tmp;
97d164
< bar = _LAW_BAR(addr);
101,103c168,170
< for (i = 0; i < law_max; i++)
< if (sr == ccsr_read4(OCP85XX_LAWSR(i)) &&
< bar == ccsr_read4(OCP85XX_LAWBAR(i)))
---
> for (i = 0; i < law_max; i++) {
> law_read(i, &bar_tmp, &sr_tmp);
> if (sr == sr_tmp && bar == bar_tmp)
104a172
> }
107,109c175
< for (i = 0; i < law_max; i++)
< if ((ccsr_read4(OCP85XX_LAWSR(i)) & 0x80000000) == 0)
< break;
---
> i = law_find_free();
114,115c180
< ccsr_write4(OCP85XX_LAWBAR(i), bar);
< ccsr_write4(OCP85XX_LAWSR(i), sr);
---
> law_write(i, bar, sr);
120c185
< law_disable(int trgt, u_long addr, u_long size)
---
> law_disable(int trgt, uint64_t bar, uint32_t size)
122c187,188
< uint32_t bar, sr;
---
> uint64_t bar_tmp;
> uint32_t sr, sr_tmp;
126d191
< bar = _LAW_BAR(addr);
130,134c195,198
< for (i = 0; i < law_max; i++)
< if (sr == ccsr_read4(OCP85XX_LAWSR(i)) &&
< bar == ccsr_read4(OCP85XX_LAWBAR(i))) {
< ccsr_write4(OCP85XX_LAWBAR(i), 0);
< ccsr_write4(OCP85XX_LAWSR(i), 0);
---
> for (i = 0; i < law_max; i++) {
> law_read(i, &bar_tmp, &sr_tmp);
> if (sr == sr_tmp && bar == bar_tmp) {
> law_write(i, 0, 0);
136a201
> }
154a220
> case 0x0000:
157a224
> case 0x1000:
160a228
> case 0x2000:
166a235
> case 0x3000:
< __FBSDID("$FreeBSD: head/sys/powerpc/mpc85xx/mpc85xx.c 257178 2013-10-26 18:18:14Z nwhitehorn $");
---
> __FBSDID("$FreeBSD: head/sys/powerpc/mpc85xx/mpc85xx.c 291008 2015-11-18 01:54:19Z jhibbits $");
29a30
> #include "opt_platform.h"
47a49
>
72a75
> int law_max;
75,79c78,95
< if (ver == SVR_MPC8555E || ver == SVR_MPC8555)
< return (8);
< if (ver == SVR_MPC8548E || ver == SVR_MPC8548 ||
< ver == SVR_MPC8533E || ver == SVR_MPC8533)
< return (10);
---
> switch (ver) {
> case SVR_MPC8555:
> case SVR_MPC8555E:
> law_max = 8;
> break;
> case SVR_MPC8533:
> case SVR_MPC8533E:
> case SVR_MPC8548:
> case SVR_MPC8548E:
> law_max = 10;
> break;
> case SVR_P5020:
> case SVR_P5020E:
> law_max = 32;
> break;
> default:
> law_max = 8;
> }
81c97
< return (12);
---
> return (law_max);
83a100,151
> static inline void
> law_write(uint32_t n, uint64_t bar, uint32_t sr)
> {
> #if defined(QORIQ_DPAA)
> ccsr_write4(OCP85XX_LAWBARH(n), bar >> 32);
> ccsr_write4(OCP85XX_LAWBARL(n), bar);
> #else
> ccsr_write4(OCP85XX_LAWBAR(n), bar >> 12);
> #endif
> ccsr_write4(OCP85XX_LAWSR(n), sr);
>
> /*
> * The last write to LAWAR should be followed by a read
> * of LAWAR before any device try to use any of windows.
> * What more the read of LAWAR should be followed by isync
> * instruction.
> */
>
> ccsr_read4(OCP85XX_LAWSR(n));
> isync();
> }
>
> static inline void
> law_read(uint32_t n, uint64_t *bar, uint32_t *sr)
> {
> #if defined(QORIQ_DPAA)
> *bar = (uint64_t)ccsr_read4(OCP85XX_LAWBARH(n)) << 32 |
> ccsr_read4(OCP85XX_LAWBARL(n));
> #else
> *bar = (uint64_t)ccsr_read4(OCP85XX_LAWBAR(n)) << 12;
> #endif
> *sr = ccsr_read4(OCP85XX_LAWSR(n));
> }
>
> static int
> law_find_free(void)
> {
> uint32_t i,sr;
> uint64_t bar;
> int law_max;
>
> law_max = law_getmax();
> /* Find free LAW */
> for (i = 0; i < law_max; i++) {
> law_read(i, &bar, &sr);
> if ((sr & 0x80000000) == 0)
> break;
> }
>
> return (i);
> }
>
85d152
< #define _LAW_BAR(addr) (addr >> 12)
88c155
< law_enable(int trgt, u_long addr, u_long size)
---
> law_enable(int trgt, uint64_t bar, uint32_t size)
90c157,158
< uint32_t bar, sr;
---
> uint64_t bar_tmp;
> uint32_t sr, sr_tmp;
97d164
< bar = _LAW_BAR(addr);
101,103c168,170
< for (i = 0; i < law_max; i++)
< if (sr == ccsr_read4(OCP85XX_LAWSR(i)) &&
< bar == ccsr_read4(OCP85XX_LAWBAR(i)))
---
> for (i = 0; i < law_max; i++) {
> law_read(i, &bar_tmp, &sr_tmp);
> if (sr == sr_tmp && bar == bar_tmp)
104a172
> }
107,109c175
< for (i = 0; i < law_max; i++)
< if ((ccsr_read4(OCP85XX_LAWSR(i)) & 0x80000000) == 0)
< break;
---
> i = law_find_free();
114,115c180
< ccsr_write4(OCP85XX_LAWBAR(i), bar);
< ccsr_write4(OCP85XX_LAWSR(i), sr);
---
> law_write(i, bar, sr);
120c185
< law_disable(int trgt, u_long addr, u_long size)
---
> law_disable(int trgt, uint64_t bar, uint32_t size)
122c187,188
< uint32_t bar, sr;
---
> uint64_t bar_tmp;
> uint32_t sr, sr_tmp;
126d191
< bar = _LAW_BAR(addr);
130,134c195,198
< for (i = 0; i < law_max; i++)
< if (sr == ccsr_read4(OCP85XX_LAWSR(i)) &&
< bar == ccsr_read4(OCP85XX_LAWBAR(i))) {
< ccsr_write4(OCP85XX_LAWBAR(i), 0);
< ccsr_write4(OCP85XX_LAWSR(i), 0);
---
> for (i = 0; i < law_max; i++) {
> law_read(i, &bar_tmp, &sr_tmp);
> if (sr == sr_tmp && bar == bar_tmp) {
> law_write(i, 0, 0);
136a201
> }
154a220
> case 0x0000:
157a224
> case 0x1000:
160a228
> case 0x2000:
166a235
> case 0x3000: