]>
git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/blob - drivers/net/dsa/mv88e6xxx/global1_atu.c
2 * Marvell 88E6xxx Address Translation Unit (ATU) support
4 * Copyright (c) 2008 Marvell Semiconductor
5 * Copyright (c) 2017 Savoir-faire Linux, Inc.
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
13 #include "mv88e6xxx.h"
16 /* Offset 0x0A: ATU Control Register */
18 int mv88e6xxx_g1_atu_set_age_time(struct mv88e6xxx_chip
*chip
,
21 const unsigned int coeff
= chip
->info
->age_time_coeff
;
22 const unsigned int min
= 0x01 * coeff
;
23 const unsigned int max
= 0xff * coeff
;
28 if (msecs
< min
|| msecs
> max
)
31 /* Round to nearest multiple of coeff */
32 age_time
= (msecs
+ coeff
/ 2) / coeff
;
34 err
= mv88e6xxx_g1_read(chip
, GLOBAL_ATU_CONTROL
, &val
);
38 /* AgeTime is 11:4 bits */
42 return mv88e6xxx_g1_write(chip
, GLOBAL_ATU_CONTROL
, val
);