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

ARM: OMAP2+: gpmc: generic timing calculation

Presently there are three peripherals that gets it timing
by runtime calculation. Those peripherals can work with
frequency scaling that affects gpmc clock. But timing
calculation for them are in different ways.

Here a generic runtime calculation method is proposed. Input
to this function were selected so that they represent timing
variables that are present in peripheral datasheets. Motive
behind this was to achieve DT bindings for the inputs as is.
Even though a few of the tusb6010 timings could not be made
directly related to timings normally found on peripherals,
expressions used were translated to those that could be
justified.

There are possibilities of improving the calculations, like
calculating timing for read & write operations in a more
similar way. Expressions derived here were tested for async
onenand on omap3evm (as vanilla Kernel does not have omap3evm
onenand support, local patch was used). Other peripherals,
tusb6010, smc91x calculations were validated by simulating
on omap3evm.

Regarding "we_on" for onenand async, it was found that even
for muxed address/data, it need not be greater than
"adv_wr_off", but rather could be derived from write setup
time for peripheral from start of access time, hence would
more be in line with peripheral timings. With this method
it was working fine. If it is required in some cases to
have "we_on" same as "wr_data_mux_bus" (i.e. greater than
"adv_wr_off"), another variable could be added to indicate
it. But such a requirement is not expected though.

It has been observed that "adv_rd_off" & "adv_wr_off" are
currently calculated by adding an offset over "oe_on" and
"we_on" respectively in the case of smc91x. But peripheral
datasheet does not specify so and so "adv_rd(wr)_off" has
been derived (to be specific, made ignorant of "oe_on" and
"we_on") observing datasheet rather than adding an offset.
Hence this generic routine is expected to work for smc91x
(91C96 RX51 board). This was verified on smsc911x (9220 on
OMAP3EVM) - a similar ethernet controller.

Timings are calculated in ps to prevent rounding errors and
converted to ns at final stage so that these values can be
directly fed to gpmc_cs_set_timings(). gpmc_cs_set_timings()
would be modified to take ps once all custom timing routines
are replaced by the generic routine, at the same time
generic timing routine would be modified to provide timings
in ps. struct gpmc_timings field types are upgraded from
u16 => u32 so that it can hold ps values.

Whole of this exercise is being done to achieve driver and
DT conversion. If timings could not be calculated in a
peripheral agnostic way, either gpmc driver would have to
be peripheral gnostic or a wrapper arrangement over gpmc
driver would be required.

Signed-off-by: Afzal Mohammed <afzal@ti.com>

+529 -20
+122
Documentation/bus-devices/ti-gpmc.txt
··· 1 + GPMC (General Purpose Memory Controller): 2 + ========================================= 3 + 4 + GPMC is an unified memory controller dedicated to interfacing external 5 + memory devices like 6 + * Asynchronous SRAM like memories and application specific integrated 7 + circuit devices. 8 + * Asynchronous, synchronous, and page mode burst NOR flash devices 9 + NAND flash 10 + * Pseudo-SRAM devices 11 + 12 + GPMC is found on Texas Instruments SoC's (OMAP based) 13 + IP details: http://www.ti.com/lit/pdf/spruh73 section 7.1 14 + 15 + 16 + GPMC generic timing calculation: 17 + ================================ 18 + 19 + GPMC has certain timings that has to be programmed for proper 20 + functioning of the peripheral, while peripheral has another set of 21 + timings. To have peripheral work with gpmc, peripheral timings has to 22 + be translated to the form gpmc can understand. The way it has to be 23 + translated depends on the connected peripheral. Also there is a 24 + dependency for certain gpmc timings on gpmc clock frequency. Hence a 25 + generic timing routine was developed to achieve above requirements. 26 + 27 + Generic routine provides a generic method to calculate gpmc timings 28 + from gpmc peripheral timings. struct gpmc_device_timings fields has to 29 + be updated with timings from the datasheet of the peripheral that is 30 + connected to gpmc. A few of the peripheral timings can be fed either 31 + in time or in cycles, provision to handle this scenario has been 32 + provided (refer struct gpmc_device_timings definition). It may so 33 + happen that timing as specified by peripheral datasheet is not present 34 + in timing structure, in this scenario, try to correlate peripheral 35 + timing to the one available. If that doesn't work, try to add a new 36 + field as required by peripheral, educate generic timing routine to 37 + handle it, make sure that it does not break any of the existing. 38 + Then there may be cases where peripheral datasheet doesn't mention 39 + certain fields of struct gpmc_device_timings, zero those entries. 40 + 41 + Generic timing routine has been verified to work properly on 42 + multiple onenand's and tusb6010 peripherals. 43 + 44 + A word of caution: generic timing routine has been developed based 45 + on understanding of gpmc timings, peripheral timings, available 46 + custom timing routines, a kind of reverse engineering without 47 + most of the datasheets & hardware (to be exact none of those supported 48 + in mainline having custom timing routine) and by simulation. 49 + 50 + gpmc timing dependency on peripheral timings: 51 + [<gpmc_timing>: <peripheral timing1>, <peripheral timing2> ...] 52 + 53 + 1. common 54 + cs_on: t_ceasu 55 + adv_on: t_avdasu, t_ceavd 56 + 57 + 2. sync common 58 + sync_clk: clk 59 + page_burst_access: t_bacc 60 + clk_activation: t_ces, t_avds 61 + 62 + 3. read async muxed 63 + adv_rd_off: t_avdp_r 64 + oe_on: t_oeasu, t_aavdh 65 + access: t_iaa, t_oe, t_ce, t_aa 66 + rd_cycle: t_rd_cycle, t_cez_r, t_oez 67 + 68 + 4. read async non-muxed 69 + adv_rd_off: t_avdp_r 70 + oe_on: t_oeasu 71 + access: t_iaa, t_oe, t_ce, t_aa 72 + rd_cycle: t_rd_cycle, t_cez_r, t_oez 73 + 74 + 5. read sync muxed 75 + adv_rd_off: t_avdp_r, t_avdh 76 + oe_on: t_oeasu, t_ach, cyc_aavdh_oe 77 + access: t_iaa, cyc_iaa, cyc_oe 78 + rd_cycle: t_cez_r, t_oez, t_ce_rdyz 79 + 80 + 6. read sync non-muxed 81 + adv_rd_off: t_avdp_r 82 + oe_on: t_oeasu 83 + access: t_iaa, cyc_iaa, cyc_oe 84 + rd_cycle: t_cez_r, t_oez, t_ce_rdyz 85 + 86 + 7. write async muxed 87 + adv_wr_off: t_avdp_w 88 + we_on, wr_data_mux_bus: t_weasu, t_aavdh, cyc_aavhd_we 89 + we_off: t_wpl 90 + cs_wr_off: t_wph 91 + wr_cycle: t_cez_w, t_wr_cycle 92 + 93 + 8. write async non-muxed 94 + adv_wr_off: t_avdp_w 95 + we_on, wr_data_mux_bus: t_weasu 96 + we_off: t_wpl 97 + cs_wr_off: t_wph 98 + wr_cycle: t_cez_w, t_wr_cycle 99 + 100 + 9. write sync muxed 101 + adv_wr_off: t_avdp_w, t_avdh 102 + we_on, wr_data_mux_bus: t_weasu, t_rdyo, t_aavdh, cyc_aavhd_we 103 + we_off: t_wpl, cyc_wpl 104 + cs_wr_off: t_wph 105 + wr_cycle: t_cez_w, t_ce_rdyz 106 + 107 + 10. write sync non-muxed 108 + adv_wr_off: t_avdp_w 109 + we_on, wr_data_mux_bus: t_weasu, t_rdyo 110 + we_off: t_wpl, cyc_wpl 111 + cs_wr_off: t_wph 112 + wr_cycle: t_cez_w, t_ce_rdyz 113 + 114 + 115 + Note: Many of gpmc timings are dependent on other gpmc timings (a few 116 + gpmc timings purely dependent on other gpmc timings, a reason that 117 + some of the gpmc timings are missing above), and it will result in 118 + indirect dependency of peripheral timings to gpmc timings other than 119 + mentioned above, refer timing routine for more details. To know what 120 + these peripheral timings correspond to, please see explanations in 121 + struct gpmc_device_timings definition. And for gpmc timings refer 122 + IP details (link above).
+325
arch/arm/mach-omap2/gpmc.c
··· 230 230 return ticks * gpmc_get_fclk_period() / 1000; 231 231 } 232 232 233 + static unsigned int gpmc_ticks_to_ps(unsigned int ticks) 234 + { 235 + return ticks * gpmc_get_fclk_period(); 236 + } 237 + 238 + static unsigned int gpmc_round_ps_to_ticks(unsigned int time_ps) 239 + { 240 + unsigned long ticks = gpmc_ps_to_ticks(time_ps); 241 + 242 + return ticks * gpmc_get_fclk_period(); 243 + } 244 + 233 245 static inline void gpmc_cs_modify_reg(int cs, int reg, u32 mask, bool value) 234 246 { 235 247 u32 l; ··· 804 792 return rc; 805 793 } 806 794 } 795 + 796 + return 0; 797 + } 798 + 799 + static u32 gpmc_round_ps_to_sync_clk(u32 time_ps, u32 sync_clk) 800 + { 801 + u32 temp; 802 + int div; 803 + 804 + div = gpmc_calc_divider(sync_clk); 805 + temp = gpmc_ps_to_ticks(time_ps); 806 + temp = (temp + div - 1) / div; 807 + return gpmc_ticks_to_ps(temp * div); 808 + } 809 + 810 + /* XXX: can the cycles be avoided ? */ 811 + static int gpmc_calc_sync_read_timings(struct gpmc_timings *gpmc_t, 812 + struct gpmc_device_timings *dev_t) 813 + { 814 + bool mux = dev_t->mux; 815 + u32 temp; 816 + 817 + /* adv_rd_off */ 818 + temp = dev_t->t_avdp_r; 819 + /* XXX: mux check required ? */ 820 + if (mux) { 821 + /* XXX: t_avdp not to be required for sync, only added for tusb 822 + * this indirectly necessitates requirement of t_avdp_r and 823 + * t_avdp_w instead of having a single t_avdp 824 + */ 825 + temp = max_t(u32, temp, gpmc_t->clk_activation + dev_t->t_avdh); 826 + temp = max_t(u32, gpmc_t->adv_on + gpmc_ticks_to_ps(1), temp); 827 + } 828 + gpmc_t->adv_rd_off = gpmc_round_ps_to_ticks(temp); 829 + 830 + /* oe_on */ 831 + temp = dev_t->t_oeasu; /* XXX: remove this ? */ 832 + if (mux) { 833 + temp = max_t(u32, temp, gpmc_t->clk_activation + dev_t->t_ach); 834 + temp = max_t(u32, temp, gpmc_t->adv_rd_off + 835 + gpmc_ticks_to_ps(dev_t->cyc_aavdh_oe)); 836 + } 837 + gpmc_t->oe_on = gpmc_round_ps_to_ticks(temp); 838 + 839 + /* access */ 840 + /* XXX: any scope for improvement ?, by combining oe_on 841 + * and clk_activation, need to check whether 842 + * access = clk_activation + round to sync clk ? 843 + */ 844 + temp = max_t(u32, dev_t->t_iaa, dev_t->cyc_iaa * gpmc_t->sync_clk); 845 + temp += gpmc_t->clk_activation; 846 + if (dev_t->cyc_oe) 847 + temp = max_t(u32, temp, gpmc_t->oe_on + 848 + gpmc_ticks_to_ps(dev_t->cyc_oe)); 849 + gpmc_t->access = gpmc_round_ps_to_ticks(temp); 850 + 851 + gpmc_t->oe_off = gpmc_t->access + gpmc_ticks_to_ps(1); 852 + gpmc_t->cs_rd_off = gpmc_t->oe_off; 853 + 854 + /* rd_cycle */ 855 + temp = max_t(u32, dev_t->t_cez_r, dev_t->t_oez); 856 + temp = gpmc_round_ps_to_sync_clk(temp, gpmc_t->sync_clk) + 857 + gpmc_t->access; 858 + /* XXX: barter t_ce_rdyz with t_cez_r ? */ 859 + if (dev_t->t_ce_rdyz) 860 + temp = max_t(u32, temp, gpmc_t->cs_rd_off + dev_t->t_ce_rdyz); 861 + gpmc_t->rd_cycle = gpmc_round_ps_to_ticks(temp); 862 + 863 + return 0; 864 + } 865 + 866 + static int gpmc_calc_sync_write_timings(struct gpmc_timings *gpmc_t, 867 + struct gpmc_device_timings *dev_t) 868 + { 869 + bool mux = dev_t->mux; 870 + u32 temp; 871 + 872 + /* adv_wr_off */ 873 + temp = dev_t->t_avdp_w; 874 + if (mux) { 875 + temp = max_t(u32, temp, 876 + gpmc_t->clk_activation + dev_t->t_avdh); 877 + temp = max_t(u32, gpmc_t->adv_on + gpmc_ticks_to_ps(1), temp); 878 + } 879 + gpmc_t->adv_wr_off = gpmc_round_ps_to_ticks(temp); 880 + 881 + /* wr_data_mux_bus */ 882 + temp = max_t(u32, dev_t->t_weasu, 883 + gpmc_t->clk_activation + dev_t->t_rdyo); 884 + /* XXX: shouldn't mux be kept as a whole for wr_data_mux_bus ?, 885 + * and in that case remember to handle we_on properly 886 + */ 887 + if (mux) { 888 + temp = max_t(u32, temp, 889 + gpmc_t->adv_wr_off + dev_t->t_aavdh); 890 + temp = max_t(u32, temp, gpmc_t->adv_wr_off + 891 + gpmc_ticks_to_ps(dev_t->cyc_aavdh_we)); 892 + } 893 + gpmc_t->wr_data_mux_bus = gpmc_round_ps_to_ticks(temp); 894 + 895 + /* we_on */ 896 + if (gpmc_capability & GPMC_HAS_WR_DATA_MUX_BUS) 897 + gpmc_t->we_on = gpmc_round_ps_to_ticks(dev_t->t_weasu); 898 + else 899 + gpmc_t->we_on = gpmc_t->wr_data_mux_bus; 900 + 901 + /* wr_access */ 902 + /* XXX: gpmc_capability check reqd ? , even if not, will not harm */ 903 + gpmc_t->wr_access = gpmc_t->access; 904 + 905 + /* we_off */ 906 + temp = gpmc_t->we_on + dev_t->t_wpl; 907 + temp = max_t(u32, temp, 908 + gpmc_t->wr_access + gpmc_ticks_to_ps(1)); 909 + temp = max_t(u32, temp, 910 + gpmc_t->we_on + gpmc_ticks_to_ps(dev_t->cyc_wpl)); 911 + gpmc_t->we_off = gpmc_round_ps_to_ticks(temp); 912 + 913 + gpmc_t->cs_wr_off = gpmc_round_ps_to_ticks(gpmc_t->we_off + 914 + dev_t->t_wph); 915 + 916 + /* wr_cycle */ 917 + temp = gpmc_round_ps_to_sync_clk(dev_t->t_cez_w, gpmc_t->sync_clk); 918 + temp += gpmc_t->wr_access; 919 + /* XXX: barter t_ce_rdyz with t_cez_w ? */ 920 + if (dev_t->t_ce_rdyz) 921 + temp = max_t(u32, temp, 922 + gpmc_t->cs_wr_off + dev_t->t_ce_rdyz); 923 + gpmc_t->wr_cycle = gpmc_round_ps_to_ticks(temp); 924 + 925 + return 0; 926 + } 927 + 928 + static int gpmc_calc_async_read_timings(struct gpmc_timings *gpmc_t, 929 + struct gpmc_device_timings *dev_t) 930 + { 931 + bool mux = dev_t->mux; 932 + u32 temp; 933 + 934 + /* adv_rd_off */ 935 + temp = dev_t->t_avdp_r; 936 + if (mux) 937 + temp = max_t(u32, gpmc_t->adv_on + gpmc_ticks_to_ps(1), temp); 938 + gpmc_t->adv_rd_off = gpmc_round_ps_to_ticks(temp); 939 + 940 + /* oe_on */ 941 + temp = dev_t->t_oeasu; 942 + if (mux) 943 + temp = max_t(u32, temp, 944 + gpmc_t->adv_rd_off + dev_t->t_aavdh); 945 + gpmc_t->oe_on = gpmc_round_ps_to_ticks(temp); 946 + 947 + /* access */ 948 + temp = max_t(u32, dev_t->t_iaa, /* XXX: remove t_iaa in async ? */ 949 + gpmc_t->oe_on + dev_t->t_oe); 950 + temp = max_t(u32, temp, 951 + gpmc_t->cs_on + dev_t->t_ce); 952 + temp = max_t(u32, temp, 953 + gpmc_t->adv_on + dev_t->t_aa); 954 + gpmc_t->access = gpmc_round_ps_to_ticks(temp); 955 + 956 + gpmc_t->oe_off = gpmc_t->access + gpmc_ticks_to_ps(1); 957 + gpmc_t->cs_rd_off = gpmc_t->oe_off; 958 + 959 + /* rd_cycle */ 960 + temp = max_t(u32, dev_t->t_rd_cycle, 961 + gpmc_t->cs_rd_off + dev_t->t_cez_r); 962 + temp = max_t(u32, temp, gpmc_t->oe_off + dev_t->t_oez); 963 + gpmc_t->rd_cycle = gpmc_round_ps_to_ticks(temp); 964 + 965 + return 0; 966 + } 967 + 968 + static int gpmc_calc_async_write_timings(struct gpmc_timings *gpmc_t, 969 + struct gpmc_device_timings *dev_t) 970 + { 971 + bool mux = dev_t->mux; 972 + u32 temp; 973 + 974 + /* adv_wr_off */ 975 + temp = dev_t->t_avdp_w; 976 + if (mux) 977 + temp = max_t(u32, gpmc_t->adv_on + gpmc_ticks_to_ps(1), temp); 978 + gpmc_t->adv_wr_off = gpmc_round_ps_to_ticks(temp); 979 + 980 + /* wr_data_mux_bus */ 981 + temp = dev_t->t_weasu; 982 + if (mux) { 983 + temp = max_t(u32, temp, gpmc_t->adv_wr_off + dev_t->t_aavdh); 984 + temp = max_t(u32, temp, gpmc_t->adv_wr_off + 985 + gpmc_ticks_to_ps(dev_t->cyc_aavdh_we)); 986 + } 987 + gpmc_t->wr_data_mux_bus = gpmc_round_ps_to_ticks(temp); 988 + 989 + /* we_on */ 990 + if (gpmc_capability & GPMC_HAS_WR_DATA_MUX_BUS) 991 + gpmc_t->we_on = gpmc_round_ps_to_ticks(dev_t->t_weasu); 992 + else 993 + gpmc_t->we_on = gpmc_t->wr_data_mux_bus; 994 + 995 + /* we_off */ 996 + temp = gpmc_t->we_on + dev_t->t_wpl; 997 + gpmc_t->we_off = gpmc_round_ps_to_ticks(temp); 998 + 999 + gpmc_t->cs_wr_off = gpmc_round_ps_to_ticks(gpmc_t->we_off + 1000 + dev_t->t_wph); 1001 + 1002 + /* wr_cycle */ 1003 + temp = max_t(u32, dev_t->t_wr_cycle, 1004 + gpmc_t->cs_wr_off + dev_t->t_cez_w); 1005 + gpmc_t->wr_cycle = gpmc_round_ps_to_ticks(temp); 1006 + 1007 + return 0; 1008 + } 1009 + 1010 + static int gpmc_calc_sync_common_timings(struct gpmc_timings *gpmc_t, 1011 + struct gpmc_device_timings *dev_t) 1012 + { 1013 + u32 temp; 1014 + 1015 + gpmc_t->sync_clk = gpmc_calc_divider(dev_t->clk) * 1016 + gpmc_get_fclk_period(); 1017 + 1018 + gpmc_t->page_burst_access = gpmc_round_ps_to_sync_clk( 1019 + dev_t->t_bacc, 1020 + gpmc_t->sync_clk); 1021 + 1022 + temp = max_t(u32, dev_t->t_ces, dev_t->t_avds); 1023 + gpmc_t->clk_activation = gpmc_round_ps_to_ticks(temp); 1024 + 1025 + if (gpmc_calc_divider(gpmc_t->sync_clk) != 1) 1026 + return 0; 1027 + 1028 + if (dev_t->ce_xdelay) 1029 + gpmc_t->bool_timings.cs_extra_delay = true; 1030 + if (dev_t->avd_xdelay) 1031 + gpmc_t->bool_timings.adv_extra_delay = true; 1032 + if (dev_t->oe_xdelay) 1033 + gpmc_t->bool_timings.oe_extra_delay = true; 1034 + if (dev_t->we_xdelay) 1035 + gpmc_t->bool_timings.we_extra_delay = true; 1036 + 1037 + return 0; 1038 + } 1039 + 1040 + static int gpmc_calc_common_timings(struct gpmc_timings *gpmc_t, 1041 + struct gpmc_device_timings *dev_t) 1042 + { 1043 + u32 temp; 1044 + 1045 + /* cs_on */ 1046 + gpmc_t->cs_on = gpmc_round_ps_to_ticks(dev_t->t_ceasu); 1047 + 1048 + /* adv_on */ 1049 + temp = dev_t->t_avdasu; 1050 + if (dev_t->t_ce_avd) 1051 + temp = max_t(u32, temp, 1052 + gpmc_t->cs_on + dev_t->t_ce_avd); 1053 + gpmc_t->adv_on = gpmc_round_ps_to_ticks(temp); 1054 + 1055 + if (dev_t->sync_write || dev_t->sync_read) 1056 + gpmc_calc_sync_common_timings(gpmc_t, dev_t); 1057 + 1058 + return 0; 1059 + } 1060 + 1061 + /* TODO: remove this function once all peripherals are confirmed to 1062 + * work with generic timing. Simultaneously gpmc_cs_set_timings() 1063 + * has to be modified to handle timings in ps instead of ns 1064 + */ 1065 + static void gpmc_convert_ps_to_ns(struct gpmc_timings *t) 1066 + { 1067 + t->cs_on /= 1000; 1068 + t->cs_rd_off /= 1000; 1069 + t->cs_wr_off /= 1000; 1070 + t->adv_on /= 1000; 1071 + t->adv_rd_off /= 1000; 1072 + t->adv_wr_off /= 1000; 1073 + t->we_on /= 1000; 1074 + t->we_off /= 1000; 1075 + t->oe_on /= 1000; 1076 + t->oe_off /= 1000; 1077 + t->page_burst_access /= 1000; 1078 + t->access /= 1000; 1079 + t->rd_cycle /= 1000; 1080 + t->wr_cycle /= 1000; 1081 + t->bus_turnaround /= 1000; 1082 + t->cycle2cycle_delay /= 1000; 1083 + t->wait_monitoring /= 1000; 1084 + t->clk_activation /= 1000; 1085 + t->wr_access /= 1000; 1086 + t->wr_data_mux_bus /= 1000; 1087 + } 1088 + 1089 + int gpmc_calc_timings(struct gpmc_timings *gpmc_t, 1090 + struct gpmc_device_timings *dev_t) 1091 + { 1092 + memset(gpmc_t, 0, sizeof(*gpmc_t)); 1093 + 1094 + gpmc_calc_common_timings(gpmc_t, dev_t); 1095 + 1096 + if (dev_t->sync_read) 1097 + gpmc_calc_sync_read_timings(gpmc_t, dev_t); 1098 + else 1099 + gpmc_calc_async_read_timings(gpmc_t, dev_t); 1100 + 1101 + if (dev_t->sync_write) 1102 + gpmc_calc_sync_write_timings(gpmc_t, dev_t); 1103 + else 1104 + gpmc_calc_async_write_timings(gpmc_t, dev_t); 1105 + 1106 + /* TODO: remove, see function definition */ 1107 + gpmc_convert_ps_to_ns(gpmc_t); 807 1108 808 1109 return 0; 809 1110 }
+82 -20
arch/arm/mach-omap2/gpmc.h
··· 94 94 u32 sync_clk; 95 95 96 96 /* Chip-select signal timings corresponding to GPMC_CS_CONFIG2 */ 97 - u16 cs_on; /* Assertion time */ 98 - u16 cs_rd_off; /* Read deassertion time */ 99 - u16 cs_wr_off; /* Write deassertion time */ 97 + u32 cs_on; /* Assertion time */ 98 + u32 cs_rd_off; /* Read deassertion time */ 99 + u32 cs_wr_off; /* Write deassertion time */ 100 100 101 101 /* ADV signal timings corresponding to GPMC_CONFIG3 */ 102 - u16 adv_on; /* Assertion time */ 103 - u16 adv_rd_off; /* Read deassertion time */ 104 - u16 adv_wr_off; /* Write deassertion time */ 102 + u32 adv_on; /* Assertion time */ 103 + u32 adv_rd_off; /* Read deassertion time */ 104 + u32 adv_wr_off; /* Write deassertion time */ 105 105 106 106 /* WE signals timings corresponding to GPMC_CONFIG4 */ 107 - u16 we_on; /* WE assertion time */ 108 - u16 we_off; /* WE deassertion time */ 107 + u32 we_on; /* WE assertion time */ 108 + u32 we_off; /* WE deassertion time */ 109 109 110 110 /* OE signals timings corresponding to GPMC_CONFIG4 */ 111 - u16 oe_on; /* OE assertion time */ 112 - u16 oe_off; /* OE deassertion time */ 111 + u32 oe_on; /* OE assertion time */ 112 + u32 oe_off; /* OE deassertion time */ 113 113 114 114 /* Access time and cycle time timings corresponding to GPMC_CONFIG5 */ 115 - u16 page_burst_access; /* Multiple access word delay */ 116 - u16 access; /* Start-cycle to first data valid delay */ 117 - u16 rd_cycle; /* Total read cycle time */ 118 - u16 wr_cycle; /* Total write cycle time */ 115 + u32 page_burst_access; /* Multiple access word delay */ 116 + u32 access; /* Start-cycle to first data valid delay */ 117 + u32 rd_cycle; /* Total read cycle time */ 118 + u32 wr_cycle; /* Total write cycle time */ 119 119 120 - u16 bus_turnaround; 121 - u16 cycle2cycle_delay; 120 + u32 bus_turnaround; 121 + u32 cycle2cycle_delay; 122 122 123 - u16 wait_monitoring; 124 - u16 clk_activation; 123 + u32 wait_monitoring; 124 + u32 clk_activation; 125 125 126 126 /* The following are only on OMAP3430 */ 127 - u16 wr_access; /* WRACCESSTIME */ 128 - u16 wr_data_mux_bus; /* WRDATAONADMUXBUS */ 127 + u32 wr_access; /* WRACCESSTIME */ 128 + u32 wr_data_mux_bus; /* WRDATAONADMUXBUS */ 129 129 130 130 struct gpmc_bool_timings bool_timings; 131 131 }; 132 + 133 + /* Device timings in picoseconds */ 134 + struct gpmc_device_timings { 135 + u32 t_ceasu; /* address setup to CS valid */ 136 + u32 t_avdasu; /* address setup to ADV valid */ 137 + /* XXX: try to combine t_avdp_r & t_avdp_w. Issue is 138 + * of tusb using these timings even for sync whilst 139 + * ideally for adv_rd/(wr)_off it should have considered 140 + * t_avdh instead. This indirectly necessitates r/w 141 + * variations of t_avdp as it is possible to have one 142 + * sync & other async 143 + */ 144 + u32 t_avdp_r; /* ADV low time (what about t_cer ?) */ 145 + u32 t_avdp_w; 146 + u32 t_aavdh; /* address hold time */ 147 + u32 t_oeasu; /* address setup to OE valid */ 148 + u32 t_aa; /* access time from ADV assertion */ 149 + u32 t_iaa; /* initial access time */ 150 + u32 t_oe; /* access time from OE assertion */ 151 + u32 t_ce; /* access time from CS asertion */ 152 + u32 t_rd_cycle; /* read cycle time */ 153 + u32 t_cez_r; /* read CS deassertion to high Z */ 154 + u32 t_cez_w; /* write CS deassertion to high Z */ 155 + u32 t_oez; /* OE deassertion to high Z */ 156 + u32 t_weasu; /* address setup to WE valid */ 157 + u32 t_wpl; /* write assertion time */ 158 + u32 t_wph; /* write deassertion time */ 159 + u32 t_wr_cycle; /* write cycle time */ 160 + 161 + u32 clk; 162 + u32 t_bacc; /* burst access valid clock to output delay */ 163 + u32 t_ces; /* CS setup time to clk */ 164 + u32 t_avds; /* ADV setup time to clk */ 165 + u32 t_avdh; /* ADV hold time from clk */ 166 + u32 t_ach; /* address hold time from clk */ 167 + u32 t_rdyo; /* clk to ready valid */ 168 + 169 + u32 t_ce_rdyz; /* XXX: description ?, or use t_cez instead */ 170 + u32 t_ce_avd; /* CS on to ADV on delay */ 171 + 172 + /* XXX: check the possibility of combining 173 + * cyc_aavhd_oe & cyc_aavdh_we 174 + */ 175 + u8 cyc_aavdh_oe;/* read address hold time in cycles */ 176 + u8 cyc_aavdh_we;/* write address hold time in cycles */ 177 + u8 cyc_oe; /* access time from OE assertion in cycles */ 178 + u8 cyc_wpl; /* write deassertion time in cycles */ 179 + u32 cyc_iaa; /* initial access time in cycles */ 180 + 181 + bool mux; /* address & data muxed */ 182 + bool sync_write;/* synchronous write */ 183 + bool sync_read; /* synchronous read */ 184 + 185 + /* extra delays */ 186 + bool ce_xdelay; 187 + bool avd_xdelay; 188 + bool oe_xdelay; 189 + bool we_xdelay; 190 + }; 191 + 192 + extern int gpmc_calc_timings(struct gpmc_timings *gpmc_t, 193 + struct gpmc_device_timings *dev_t); 132 194 133 195 extern void gpmc_update_nand_reg(struct gpmc_nand_regs *reg, int cs); 134 196 extern int gpmc_get_client_irq(unsigned irq_config);