Root/
| 1 | /* |
| 2 | * include/ubb/mmcclk.h - Calculate MMC bus clock speed |
| 3 | * |
| 4 | * Written 2013 by Werner Almesberger |
| 5 | * Copyright 2013 Werner Almesberger |
| 6 | * |
| 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. |
| 11 | */ |
| 12 | |
| 13 | #ifndef UBB_MMCCLK_H |
| 14 | #define UBB_MMCCLK_H |
| 15 | |
| 16 | #include <stdint.h> |
| 17 | |
| 18 | |
| 19 | #define BEN_PLL_CLK_HZ 336000000 |
| 20 | |
| 21 | |
| 22 | /* |
| 23 | * By default (flags = 0), only clocks that can be used with any mode of |
| 24 | * operation will be generated. The following flags also include clocks ... |
| 25 | */ |
| 26 | |
| 27 | #define MMCCLK_FLAG_RD_ONLY (1 << 0) /* not suitable for writing */ |
| 28 | #define MMCCLK_FLAG_WR_ONLY (1 << 1) /* not suitable for reading */ |
| 29 | #define MMCCLK_FLAG_INTERNAL (1 << 2) /* not suitable for bus use */ |
| 30 | #define MMCCLK_FLAG_UNSAFE (1 << 3) /* that may hang the MSC */ |
| 31 | #define MMCCLK_FLAG_ALL (1 << 4) /* that will hang the MSC */ |
| 32 | |
| 33 | /* |
| 34 | * For now, only MMCCLK_FLAG_UNSAFE and MMCCLK_FLAG_ALL are implemented, but |
| 35 | * further research may also reveal limits that depend on the type of |
| 36 | * operation. |
| 37 | */ |
| 38 | |
| 39 | |
| 40 | struct mmcclk { |
| 41 | int sys_clk_hz; /* system clock speed in Hz */ |
| 42 | double bus_clk_hz; /* MMC bus clock in Hz */ |
| 43 | uint32_t clkdiv; /* MSC controller clock */ |
| 44 | uint32_t clkrt; /* bus clock divider */ |
| 45 | unsigned flags; |
| 46 | }; |
| 47 | |
| 48 | |
| 49 | void mmcclk_first(struct mmcclk *dsc, int sys_clk_hz, unsigned flags); |
| 50 | int mmcclk_next(struct mmcclk *dsc); |
| 51 | |
| 52 | void mmcclk_start(struct mmcclk *dsc); |
| 53 | void mmcclk_stop(void); |
| 54 | |
| 55 | #endif /* !UBB_MMCCLK_H */ |
| 56 |
Branches:
master
