Lines Matching +full:- +full:hours
4 * (C) Copyright 2004, Li-Pro.Net <www.li-pro.net>
5 * Stephan Linz <linz@li-pro.net>
7 * SPDX-License-Identifier: GPL-2.0+
13 * - SXNI855T: it uses its own soft SPI here in this file
14 * - all other: use the external spi_xfer() function
56 /*-----------------------------------------------------------------------
65 /* ------------------------------------------------------------------------- */
76 immap->im_cpm.cp_pbdat |= PB_SPI_CE; in rtc_get()
83 tmp->tm_sec = bcd2bin (soft_spi_read ()); /* Read seconds */ in rtc_get()
84 tmp->tm_min = bcd2bin (soft_spi_read ()); /* Read minutes */ in rtc_get()
86 /* Hours are trickier */ in rtc_get()
87 spi_byte = soft_spi_read (); /* Read Hours into temporary value */ in rtc_get()
89 /* 12 hour mode bit is set (time is in 1-12 format) */ in rtc_get()
91 /* since PM we add 11 to get 0-23 for hours */ in rtc_get()
92 tmp->tm_hour = (bcd2bin (spi_byte & 0x1F)) + 11; in rtc_get()
94 /* since AM we subtract 1 to get 0-23 for hours */ in rtc_get()
95 tmp->tm_hour = (bcd2bin (spi_byte & 0x1F)) - 1; in rtc_get()
98 /* Otherwise, 0-23 hour format */ in rtc_get()
99 tmp->tm_hour = (bcd2bin (spi_byte & 0x3F)); in rtc_get()
103 tmp->tm_mday = bcd2bin (soft_spi_read ()); /* Read Day of the Month */ in rtc_get()
104 tmp->tm_mon = bcd2bin (soft_spi_read ()); /* Read Month */ in rtc_get()
107 tmp->tm_year = bcd2bin (soft_spi_read ()) + 2000; in rtc_get()
110 immap->im_cpm.cp_pbdat &= ~PB_SPI_CE; /* Disable DS1306 Chip */ in rtc_get()
115 debug ("Get DATE: %4d-%02d-%02d (wday=%d) TIME: %2d:%02d:%02d\n", in rtc_get()
116 tmp->tm_year, tmp->tm_mon, tmp->tm_mday, tmp->tm_wday, in rtc_get()
117 tmp->tm_hour, tmp->tm_min, tmp->tm_sec); in rtc_get()
122 /* ------------------------------------------------------------------------- */
132 immap->im_cpm.cp_pbdat |= PB_SPI_CE; /* Enable DS1306 Chip */ in rtc_set()
140 immap->im_cpm.cp_pbdat &= ~PB_SPI_CE; in rtc_set()
144 immap->im_cpm.cp_pbdat |= PB_SPI_CE; in rtc_set()
151 bin2bcd (tmp->tm_sec); in rtc_set()
152 soft_spi_send (bin2bcd (tmp->tm_sec)); /* Send Seconds */ in rtc_set()
153 soft_spi_send (bin2bcd (tmp->tm_min)); /* Send Minutes */ in rtc_set()
154 soft_spi_send (bin2bcd (tmp->tm_hour)); /* Send Hour */ in rtc_set()
155 soft_spi_send (bin2bcd (tmp->tm_wday)); /* Send Day of the Week */ in rtc_set()
156 soft_spi_send (bin2bcd (tmp->tm_mday)); /* Send Day of Month */ in rtc_set()
157 soft_spi_send (bin2bcd (tmp->tm_mon)); /* Send Month */ in rtc_set()
158 soft_spi_send (bin2bcd (tmp->tm_year - 2000)); /* Send Year */ in rtc_set()
161 immap->im_cpm.cp_pbdat &= ~PB_SPI_CE; /* Disable DS1306 Chip */ in rtc_set()
165 immap->im_cpm.cp_pbdat |= PB_SPI_CE; /* Enable DS1306 Chip */ in rtc_set()
173 immap->im_cpm.cp_pbdat &= ~PB_SPI_CE; /* Disable DS1306 Chip */ in rtc_set()
185 immap->im_sitk.sitk_rtck = KAPWR_KEY; in rtc_set()
186 immap->im_sit.sit_rtc = tim; in rtc_set()
189 debug ("Set DATE: %4d-%02d-%02d (wday=%d) TIME: %2d:%02d:%02d\n", in rtc_set()
190 tmp->tm_year, tmp->tm_mon, tmp->tm_mday, tmp->tm_wday, in rtc_set()
191 tmp->tm_hour, tmp->tm_min, tmp->tm_sec); in rtc_set()
196 /* ------------------------------------------------------------------------- */
204 immap->im_cpm.cp_pbdat &= ~(PB_SPI_CE | PB_SPIMOSI | PB_SPISCK); in init_spi()
207 immap->im_cpm.cp_pbdir |= (PB_SPIMOSI | PB_SPI_CE | PB_SPISCK); in init_spi()
209 immap->im_cpm.cp_pbdir &= ~PB_SPIMISO; /* Make MISO pin an input */ in init_spi()
213 /* ------------------------------------------------------------------------- */
227 immap->im_cpm.cp_pbdat |= PB_SPISCK; /* Raise SCK */ in soft_spi_send()
230 immap->im_cpm.cp_pbdat |= PB_SPIMOSI; /* Set MOSI to 1 */ in soft_spi_send()
232 immap->im_cpm.cp_pbdat &= ~PB_SPIMOSI; /* Set MOSI to 0 */ in soft_spi_send()
235 immap->im_cpm.cp_pbdat &= ~PB_SPISCK; /* Lower SCK */ in soft_spi_send()
242 /* ------------------------------------------------------------------------- */
258 immap->im_cpm.cp_pbdat |= PB_SPISCK; /* Raise SCK */ in soft_spi_read()
260 if (immap->im_cpm.cp_pbdat & PB_SPIMISO) /* Get a bit of data */ in soft_spi_read()
262 immap->im_cpm.cp_pbdat &= ~PB_SPISCK; /* Lower SCK */ in soft_spi_read()
270 /* ------------------------------------------------------------------------- */
328 tmp->tm_sec = bcd2bin (sec & 0x7F); /* convert Seconds */ in rtc_get()
329 tmp->tm_min = bcd2bin (min & 0x7F); /* convert Minutes */ in rtc_get()
331 /* convert Hours */ in rtc_get()
332 tmp->tm_hour = (hour & 0x40) in rtc_get()
335 : bcd2bin (hour & 0x1F) - 1 /* AM */ in rtc_get()
339 tmp->tm_mday = bcd2bin (mday & 0x3F); /* convert Day of the Month */ in rtc_get()
340 tmp->tm_mon = bcd2bin (mon & 0x1F); /* convert Month */ in rtc_get()
341 tmp->tm_year = bcd2bin (year) + 2000; /* convert Year */ in rtc_get()
342 tmp->tm_wday = bcd2bin (wday & 0x07) - 1; /* convert Day of the Week */ in rtc_get()
343 tmp->tm_yday = 0; in rtc_get()
344 tmp->tm_isdst = 0; in rtc_get()
346 debug ("Get DATE: %4d-%02d-%02d (wday=%d) TIME: %2d:%02d:%02d\n", in rtc_get()
347 tmp->tm_year, tmp->tm_mon, tmp->tm_mday, tmp->tm_wday, in rtc_get()
348 tmp->tm_hour, tmp->tm_min, tmp->tm_sec); in rtc_get()
353 /* ------------------------------------------------------------------------- */
369 debug ("Set DATE: %4d-%02d-%02d (wday=%d) TIME: %2d:%02d:%02d\n", in rtc_set()
370 tmp->tm_year, tmp->tm_mon, tmp->tm_mday, tmp->tm_wday, in rtc_set()
371 tmp->tm_hour, tmp->tm_min, tmp->tm_sec); in rtc_set()
373 rtc_write (RTC_SECONDS, bin2bcd (tmp->tm_sec)); in rtc_set()
374 rtc_write (RTC_MINUTES, bin2bcd (tmp->tm_min)); in rtc_set()
375 rtc_write (RTC_HOURS, bin2bcd (tmp->tm_hour)); in rtc_set()
376 rtc_write (RTC_DAY_OF_WEEK, bin2bcd (tmp->tm_wday + 1)); in rtc_set()
377 rtc_write (RTC_DATE_OF_MONTH, bin2bcd (tmp->tm_mday)); in rtc_set()
378 rtc_write (RTC_MONTH, bin2bcd (tmp->tm_mon)); in rtc_set()
379 rtc_write (RTC_YEAR, bin2bcd (tmp->tm_year - 2000)); in rtc_set()
384 /* ------------------------------------------------------------------------- */
417 /* ------------------------------------------------------------------------- */
427 /* ------------------------------------------------------------------------- */