Commit Graph

233 Commits

Author SHA1 Message Date
Warner Losh
ab45d28ce3 MFp4:
correct data counts so that we clock enough data for the spi
	transaction.  This allows complete spi transactions to happen.
2006-11-29 07:57:02 +00:00
Warner Losh
ff7447dae1 MFp4: Make it work :-)
o Don't delay when checking the done bits.  There's no gain other
	  than a small performance hit.
	o calculate the clock divisors better (things are still way slow,
	  so maybe there's more here?)
	o don't always fail reset.  Always succeed instead.
	o fix inverted logic around at91_twi_wait() return value
	o remove debug code
	o remove unneeded, unworking junk
2006-11-22 06:51:59 +00:00
Warner Losh
111bcda150 MFp4: Tweak descriptions in preparation for porting to other members of
the AT91 arm9 family.
2006-11-20 06:27:15 +00:00
Sam Leffler
faad47108d change bus space unmap protoype
Reviewed by:	cognet, imp
MFC After:	1 month
2006-11-19 23:47:51 +00:00
Alan Cox
cc0d48ffb6 Eliminate unused global variables. 2006-11-11 20:57:52 +00:00
Warner Losh
8cd5dc08c3 MFp4:
o Fix the packet statistics
	o Make sure we set the FD bit when in full duplex
	o Improve TX side efficency by eliminating a data copy for
	  unfragmented mbufs (the hardware can't do s/g).
	o Minor busdma pedantry
	o better comments in some places, more XXX in others
	o Minor style nits.

This solves a problem I was seeing where I'd get no ethernet when not
booting with a NFS root.  Well, unless I unplugged the cable and
plugged it back in first so I'd get the same up down up messages I get
for NFS root...

Thanks to sam and scottl for suggestions on making this driver more
efficient through better use of approrpiate APIs.
2006-11-03 07:39:37 +00:00
John Birrell
8460a577a4 Make KSE a kernel option, turned on by default in all GENERIC
kernel configs except sun4v (which doesn't process signals properly
with KSE).

Reviewed by:	davidxu@
2006-10-26 21:42:22 +00:00
Warner Losh
bc8fe52e6d MFp4: Move the parameters that are basically dictated by the AT91
organization to that file.
2006-10-25 08:00:11 +00:00
Warner Losh
1b104c589a MFp4: Status register bits 2006-10-25 07:58:18 +00:00
Warner Losh
0f1c5aca64 MFp4: Working SPI driver. 2006-10-20 07:10:13 +00:00
Warner Losh
89975186a3 Commit WIP SSC driver, more work is needed here, but it configures
things OK.
2006-10-20 07:08:59 +00:00
Warner Losh
bfa94035b0 More register definitions. 2006-10-20 07:08:15 +00:00
Warner Losh
5f9c612ae7 Progress commit for getting TWI working 2006-10-20 07:06:39 +00:00
Warner Losh
56878d42da Add sysctl to export current state of rmii vs mii configuraiton.
Fix a typo in resource allocation.
2006-10-20 07:04:56 +00:00
Warner Losh
e352ac0afb Add configuration of the SSC lines for second SSC. 2006-10-20 07:03:57 +00:00
Warner Losh
e41e815e5c MMC/SD bridge driver (host adapter) for AT91RM9200's MCI interface.
This interface also appears in the AT91SAM9260 and '61 as well as the
AVR32 based micros from Atmel.  We don't yet support write protect or
hot-swap in this bridge driver.
2006-10-20 06:44:04 +00:00
Warner Losh
656595aa63 MFp4: first cut at getting I2C transfers working (generically). I'm
unsure if this driver correctly implements all the start/stop junk
right (but it did or didn't before I made this commit).
2006-09-07 21:53:28 +00:00
Warner Losh
5dced01e59 MFp4: berndt pointed me at an errata that shows that the stat register
offsets were originally documented incorrectly.  This fixes that.  It
shouldn't affect anything other than error stat reporting.
2006-09-07 21:50:01 +00:00
Olivier Houchard
f35ea630e9 Relocate the vector page for AT91, to work around bugs with the LOW_VECTOR
code.
2006-08-28 20:05:00 +00:00
Olivier Houchard
223d2768ad Do not create dma maps with bus_dmamap_create, as we call
bus_dmamem_alloc later which will overwrite the value, leading to a small
memory leak.
2006-08-25 13:38:42 +00:00
Warner Losh
27e13f2b3e Hook into the watchdog device, if present. Also, turn off the
watchdog timer stuff when we boot because the boot blocks are turning
it on...
2006-08-09 20:58:55 +00:00
Olivier Houchard
49953e11d7 Rewrite ARM_USE_SMALL_ALLOC so that instead of the current behavior, it maps
whole the physical memory, cached, using 1MB section mappings. This reduces
the address space available for user processes a bit, but given the amount of
memory a typical arm machine has, it is not (yet) a big issue.
It then provides a uma_small_alloc() that works as it does for architectures
which have a direct mapping.
2006-08-08 20:59:38 +00:00
Kevin Lo
400e3077d8 Remove a bogus i = 0.
Approved by: cognet
2006-08-08 01:18:18 +00:00
Olivier Houchard
f9ad2af361 Use virtual_avail instead of freemempos as the starting point of the available
physical memory, as the vm uses the memory between freemempos and
virtual_avail.

MFC After:	3 days
2006-07-25 23:07:35 +00:00
Olivier Houchard
bba93a0066 Fix ALT_BREAK_TO_DEBUGGER on the AT91 :
The core uart code expects the receive method to actually puts the
characters read into its buffers. For AT91, it's done in the ipend routine,
so also check if we have the alternate break sequence here.

MFC after:	3 days
2006-07-20 21:03:43 +00:00
Olivier Houchard
9488796360 If we can't defrag a packet, re-queue it instead of dropping it. 2006-07-17 21:36:08 +00:00
Olivier Houchard
0769e20256 #if => #ifdef 2006-07-17 21:20:00 +00:00
Olivier Houchard
22e1aadef7 Add a comment explaining why the OHCI mapping has been commented out. 2006-07-15 00:09:53 +00:00
Warner Losh
8397a1b15c MFp4: this now depends on new spi bus stuff 2006-07-14 22:41:54 +00:00
Warner Losh
382ff28ef2 MFp4: tweaks 2006-07-14 22:40:24 +00:00
Warner Losh
2b85629b2f MFp4: elevate quality of slow clock a little 2006-07-14 22:31:12 +00:00
Warner Losh
872a109182 MFp4: paren police 2006-07-14 22:30:44 +00:00
Warner Losh
546bbbb56f MFp4:
Introduce framework to configure the multiplexed pins on boot.

	Since the USART supprots RS-485 multidrop mode, it allows the
	TX pins to float.  However, for RS-232 operations, we don't
	want these pins to float.  Instead, they should be pulled up
	to avoid mismatches.  Linux does something similar when it
	configures the TX lines.  This implies that we also allow the
	RX lines to float rather than be in the state they are left in
	by the boot loader.  Since they are input pins, I think that
	this is the right thing to do.

	Plus minor for our board.
2006-07-14 22:22:57 +00:00
Warner Losh
fa543fe2fa MFp4:
Fix typo in RTC_CALR_MK.
2006-07-14 22:06:01 +00:00
Warner Losh
92c23aea4a The TSC board uses a 16MHz base clock for the AT91RM9200, while the Kwikbyte
board uses a 10MHz base clock.  Cope with this difference.
2006-07-14 22:01:51 +00:00
Warner Losh
375906f555 Implement the set_time function. Rather pointless with this RTC, as it
resets when the core resets, but there may be some use for it...
2006-07-14 21:37:19 +00:00
Warner Losh
21caaf799a MF p4:
Adapt to forthcoming spi framework.  The ioctls for SPI commands and such
belong in the higher level driver.
2006-07-14 21:35:59 +00:00
Warner Losh
567314271b Be sure to flush the cache after a partial read on timeout. Expand
comments about timeouts.  Fix a style nit.  Sometimes small messages
were getting corrupted.
2006-07-14 21:33:04 +00:00
Warner Losh
7d73db6491 Move some of the common parameters into the std. files for this platform.
Also migrate from MD disk to NFS boot.
2006-07-14 15:20:31 +00:00
Olivier Houchard
8f395fae42 Comment out the mapping of the OHCI controller registers va == pa. This
address is in the userland address space. The proper thing is either to choose
a virtual address in the kernel address space beyond the KVA, or to use
pmap_mapdev().
2006-07-12 00:48:50 +00:00
Warner Losh
7fd083a540 Add support for configuring pins to be one of {GPIO, PERIPHERAL A or
PERIPHERAL B}, as well as direction of GPIO pin.  Add defines for all
the pins.
2006-07-02 03:50:44 +00:00
Warner Losh
d8927f1396 MFp4:
Make serial ports more robust and reliable.  Make non-console ports
work.  This might have broken skyeye stuff.

o Introduce ping-pong receive buffers.
o Use DMA to copy characters directly into memory.
o Support baud rates other than 115200
o Use 1 stop bit when 1 stop bit is requested (otherwise 2 were used,
  which caused dropped characters when received in bursts).
o Use 1.5 stop bits for 5-bit bytes, and 2 stop bits otherwise when 2
  stop bits were requested.
o Actually update line parameters.
o Fix comments
o Move init into attach
o Tweaks to TX interrupt registers to get them reliable and non-storming.
o harvest data in ipend since the latency between it and the callback
  was too long.  This likely is how it should be, I don't know why I deferred
  things to the callback before.
o disable all interrupts in console init.  We don't want interrupts until
  we turn on an ISR.
o cosmetic tweaks
o Automatically detect of the TIMEOUT interrupt is supported.  If so, use
  it so we get better CPU utilization.  Otherwise do a character at a time
  RX.  Good news here is that it seems we have enough CPU and low enough
  fast interrupt latency to do this reliably.
o Don't read USART_CR.  It is a write-only register.
o start to implement bus_ioctl.  Do BAUD now...
2006-07-02 03:45:33 +00:00
Olivier Houchard
39a0c069fa Backout previous commit, Warner committed at91_pio.c... 2006-06-23 23:07:11 +00:00
Olivier Houchard
e45fb59abe Comment out at91_pio.c, it's not in CVS. 2006-06-23 22:30:55 +00:00
Warner Losh
c0386612b8 Compute physmem so we can print it correctly on boot.
Slightly optimize while I'm here.
2006-06-20 23:40:04 +00:00
Warner Losh
57dc2664ef Probe the memory size of the board better. Look at the bus width,
number of banks, rows and columns the SDRAMC is programmed to access
to determine the RAM size for the board, rather than hard-wiring it to
be 32MB.  My company's board with 64MB now probes correctly, as does
the KB9202 with only 32MB.  This means that to detect the right memory
size, our boot loader must correctly initialize these values.  This is
a fairly safe assumption because the boot loader has to initialize
SDRAM already, and it isn't really possible to change this register
after we've accessed SDRAM.
2006-06-20 20:13:40 +00:00
Warner Losh
aee1351504 Carefully note the RMII bit in the config register at attach time.
The boot loader is supposed to leave this bit set to the right value
for the board.  If this bit was set at attach time, use it to init the
config register correctly.

Note: this means the boot loader has to properly initialize it.
2006-06-17 23:24:35 +00:00
Warner Losh
0ca5ce8fee improve reporting of clocks 2006-06-17 23:22:10 +00:00
Olivier Houchard
9464ffd0a4 MFp4: Increase the L1 pagetable needed for the kernel from 8 to 22, to be
able to boot fat kernels.
2006-06-12 22:57:24 +00:00
Warner Losh
3dcdad9a11 Remove sa1_cache_clean_addr. It isn't needed.
Submitted by: kevlo
2006-06-07 05:36:10 +00:00
Olivier Houchard
d3e6e0e6f6 We have an implementation of generic_bs_rr_1, so use it, as some drivers use
it.

Submitted by:	kevlo
2006-05-19 11:27:02 +00:00
Olivier Houchard
d5d776c16b Resurrect Skyeye support :
Add a new option, SKYEYE_WORKAROUNDS, which as the name suggests adds
workarounds for things skyeye doesn't simulate. Specifically :
- Use USART0 instead of DBGU as the console, make it not use DMA, and           manually provoke an interrupt when we're done in the transmit function.
- Skyeye maintains an internal counter for clock, but apparently there's
no way to access it, so hack the timecounter code to return a value which
is increased at every clock interrupts. This is gross, but I didn't find a
better way to implement timecounters without hacking Skyeye to get the
counter value.
- Force the write-back of PTEs once we're done writing them, even if they
are supposed to be write-through. I don't know why I have to do that.
2006-05-13 23:41:16 +00:00
Olivier Houchard
053105371f Get this to compile :
- The prototype of uart_bus_probe() hasn't been changed in cvs yet, so use the
old one.
- Add at91_pdcreg.h, needed by uart_dev_at91usart.c.
2006-05-11 14:30:28 +00:00
Warner Losh
018dc558f6 When returning a resource that we've allocated with rman_reserve_resource,
go ahead and set the rid for that resource.
2006-04-20 04:12:02 +00:00
Olivier Houchard
602c85541e MFp4: Catchup with recent UART changes. 2006-04-06 20:47:54 +00:00
Warner Losh
5ec7256cb1 Add debug writes in error cases that, in theory, should never happen 2006-04-06 04:32:29 +00:00
Warner Losh
723c740a55 Connect twi to the FreeBSD iicbus infrastructure. 2006-04-06 04:31:19 +00:00
Warner Losh
222c969f16 Pull in numerous fixes from myself and cognet. With these fixes the
KB9202 eval board is finally stable with a nfs root.
2006-04-06 04:30:23 +00:00
Warner Losh
f535b19502 Remove unused bit definitions.
Minor style cleanup while I'm here.
2006-04-06 04:29:24 +00:00
Warner Losh
b2e16e9338 Optimize the TX side of the part by using the PDC to move bytes out to
the wire.  This increases the speed considerably.  Start to put
infrastructure in place to do RX side, but that requires more study
before it can be done.
2006-04-06 04:27:19 +00:00
Warner Losh
e40dc9a60d Skeleton support for the SSC device, which implements I2S interfaces,
amoung others.
2006-03-24 07:42:33 +00:00
Warner Losh
60a5289836 Skeleton PIO support. 2006-03-24 07:39:29 +00:00
Warner Losh
c44fe487c2 Add the sekelton of support for the Power Management Controller. 2006-03-24 07:37:56 +00:00
Warner Losh
72ec44a573 Add rtc to files.at91 2006-03-24 07:36:23 +00:00
Warner Losh
74e4c374f2 Add RTC support. This may be of dubious value since the RTC is reset
to 1998 every reboot.
2006-03-24 07:35:30 +00:00
Olivier Houchard
5207a211b3 MFp4: Don't force single-user now we can go multi-user.
Call cninit() only after the pagetable has been set, as locore.S won't
map the system device for us anymore.
2006-03-22 22:31:31 +00:00
Olivier Houchard
a1de0396bd MFp4: teach the KB920x bits how to know where the ELF trampoline puts the
strtab and the symtab.
2006-03-22 21:16:51 +00:00
Olivier Houchard
eea877f42d MFp4: Handle break interrupts (it seems to only work for USART, not DBGU). 2006-03-22 21:16:09 +00:00
Warner Losh
36dd3fdf9e MFp4:
Add bus attachment for the ohci device on this chip.  The bus and hub
are detected correctly, but the children devices aren't detected
correctly for reasons unknown.
2006-03-18 01:45:29 +00:00
Warner Losh
1b0561a15d Add ohci controller mapping. 2006-03-18 01:43:54 +00:00
Warner Losh
2dc738a640 MFp4:
o update TODO list
o Better use of busdma
o mark RX dtors as COHERENT.  This helps performance a lot by not requiring
  so many EXPENSIVE cache flushes.  The cost of accessing it non-cached
  is much smaller.
o Copy data from Rx buffers to make IP header 4 byte aligned.
o CRC length included in reported length, so cope
o Don't free TX buffer twice
o Manage TX buffers better.
o Enable just the interrupts we want.
o Manage OACTIVE better

# Some of these done by cognet
# These changes let us get to # via NFS root.
2006-03-18 01:43:25 +00:00
Warner Losh
a9e7d93f31 MFP4:
Gratuitously sort alphabetically.
2006-03-18 01:39:23 +00:00
Warner Losh
f54a134552 MFP4:
GC and fix definitions.

# some of this may have been done by cognet
2006-03-18 01:38:25 +00:00
Warner Losh
f3de38a73d MFp4:
o Add memory barrier to bus space
o Allow for up to 3 IRQs per device
o Move to table driven population of children devices.
o Add support for usb ohci memory mapped controller resource allocation.
o Clean up a bunch of extra writes to disable interrupts that are now
  done elsewhere.
o Force all system interrupt handlers be fast.  We get deadlock if they
  aren't.
2006-03-18 01:35:49 +00:00
Warner Losh
5bcedfaa73 MFp4:
o Disable all interrupts that the ST can generate until we have an ISR
  to service them.
o Correct clock calculation to make DELAY the right length...

Submitted by: cognet (#2)
2006-03-18 01:30:31 +00:00
Olivier Houchard
493be2ca17 Get this to compile with the recent UART changes. 2006-02-27 23:19:13 +00:00
Warner Losh
2f415ac34d These files apply to all the atmel parts that freebsd is going to run on,
so name them more generically.  If we do support the MMU-less ARM7 parts,
then we'll need to, at that time, expand the files we have.
2006-02-17 22:33:13 +00:00
Warner Losh
77017e63bb This file was obsolete when committed. Catchup and delete it. 2006-02-17 22:23:36 +00:00
Warner Losh
e1fa2d9556 Use the correct address for the ohci device. 2006-02-11 03:58:07 +00:00
Olivier Houchard
e56b7f20a0 Set the MAC address after we just read it at attach time, as it seems needed. 2006-02-07 21:31:13 +00:00
Olivier Houchard
9bfe35c80d Set m_pkthdr.len and m_pkthdr.rcvif. 2006-02-07 20:48:52 +00:00
Olivier Houchard
ea9f99ddcd - Call mii_phy_probe() after we allocated an ifp. mii has this evil
hack where it assumes the first field of the driver softc is the struct
ifnet, and it copies its value in mii_phy_probe().
- In the interrupt handler, set the mbuf m_len field on packet receive.
2006-02-06 22:17:42 +00:00
Warner Losh
1248f2322b Import support for the Atmel AT91RM9200 CPU/Microcontroller. This SoC
is a ARM920T based CPU with a bunch of built-in peripherals.  The
inital import supports the SPI bus, the TWI bus (although iicbus
integration is not complete), the uarts, the system timer and the
onboard ethernet.  Support for the Kwikbyte KB9202
(http://www.kwikbyte.com) board is also included, although there's no
reason why the 9200 and the 9201 wouldn't also work.  Primitive
support for running under the skyeye emulator is also provided
(although skyeye's support for the AT91RM9200 is a little weak).

The code has been structured so that other members of Atmel's arm family can
be supported in the future.  The AT91SAM9260 is not presently supported
due to lack of hardware.  The arm7tdmi families are also not supported
becasue they lack an MMU.

Many thanks to cognet@ for his help and assistance in bringing up this
board.  He did much of the vm work and wrote parts of the uart and
system timer code as well as the bus space implementation.

The system boots to single user w/o problem, although the serial
console is a little slow and the ethernet driver is still in flux.

This work was sponsored by Timing Solutions, Corporation.  I am
grateful to their support of the FreeBSD project in this manner.
2006-02-04 23:32:13 +00:00