|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
8 I( z/ i" u3 H' X6 L& S#include <linux/init.h>
) _8 H6 v; T- n#include <linux/module.h>/ W/ U2 e# w1 y5 Y9 ^% m( s
#include <linux/kernel.h>* X0 Y S% X) M: t. R
#include <linux/types.h>
0 [3 b, i% S$ Z% U @7 `#include <linux/gpio.h>3 n/ r6 _8 g9 e1 J+ D
#include <linux/leds.h>
8 r6 b- z1 V" _7 L#include <linux/platform_device.h>9 e% [& k) f X) [0 I7 H/ D
# {1 J1 x. N+ W& `* g) ~#include <asm/mach-types.h>) r! }6 A. Y# p9 s
#include <asm/mach/arch.h>
8 O7 G/ z) i7 I; ?1 v- r& _$ I#include <mach/da8xx.h>
, A2 [. u: V7 k- Y5 q. `#include <mach/mux.h>' p1 Y% T1 h: W/ Q/ x
5 l% v1 w+ y0 l+ ~+ E
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
3 E8 K7 b$ ~1 c4 P. h; h4 n#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
5 y# J) |7 |7 O0 N# ?#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
5 }- @! j) u. ^( l$ K#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)& P( _: F* G$ \4 g h7 b
6 N7 U4 t, P" }# \8 \/* assign the tl som board LED-GPIOs*/
* o& c4 E- H% C, Sstatic const short da850_evm_tl_user_led_pins[] = {) e5 Z! Z6 t7 G! k$ b4 q
/* These pins are definition at <mach/mux.h> file */) t7 d+ {5 X; V/ n( Z
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
2 t" \+ _4 Q8 ?: G# w -1
1 t% _7 W9 p; k; a8 P R" j};8 N, y" C& w6 I" K! T
# @( v9 \- b8 n6 T+ z9 R3 H9 E4 ]3 I
static struct gpio_led da850_evm_tl_leds[] = {1 f: u6 h2 \, j
{
; P2 M* H: `0 N$ [6 w. @ .active_low = 0,
" f' E, i- k! }3 I# H* ^ .gpio = DA850_USER_LED0,
0 ]. c0 j( l4 I; h! \' J .name = "user_led0",
" [3 d. }$ [3 }1 A9 A4 u. Z. w; u .default_trigger = "default-on",8 E- m) M- x0 ?7 b/ `
},8 ^" `8 l8 _3 R; ~* E
{
1 d5 q$ o, Y" U# S" {. D .active_low = 0,5 J% @* g3 u& \* R, E" W0 G, E
.gpio = DA850_USER_LED1,
" _0 m$ m; c2 P' g# ]* z5 C .name = "user_led1",: V# O* H) G6 Z* C, k Z
.default_trigger = "default-on",
% ?$ f1 Z* l% L! a },+ f7 E' k. E3 X" a2 x; K" O
{
+ j% q$ t; i4 S& D8 v .active_low = 0,- V( F; e( w" A, W9 L
.gpio = DA850_USER_LED2,5 M9 t4 ~' _3 N4 ]$ w# D8 I/ i
.name = "user_led2",
) ]* m& E7 o% N7 ^9 \- t! o# Z .default_trigger = "default-on",
; ]' g$ U1 N0 S5 Q },
7 t. Z3 e& Z- \3 H {
' r& P1 [+ z4 m: f .active_low = 0,
: J# s" P2 j/ z: F .gpio = DA850_USER_LED3,( a/ M5 |, K) d" }4 D4 y0 n
.name = "user_led3",
, k7 R* D+ ^4 C! u G4 `& F .default_trigger = "default-on",
- ? \4 Y* Q/ s4 m1 m2 F }," z& b8 |- v: c- r5 J' i: ~
};4 U5 S/ [2 ~& l6 W- W
7 J- ^; n: z s; dstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
( B) L$ V6 i4 b .leds = da850_evm_tl_leds,+ S( P2 H; e- p/ Y5 k! h
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),
9 h/ I) Q$ S# M. k};" n4 L2 ^7 b3 i
& |5 Q1 r% f0 G/ m4 m# Tstatic void led_dev_release(struct device *dev)
6 w5 Z6 O7 P( M3 b' T- |{
6 a7 N0 I$ Y1 V+ p3 X3 f4 F: f/ o9 z};
' s8 | T0 N7 u# R1 d' K6 i) x5 r2 g- O
static struct platform_device da850_evm_tl_leds_device = {
4 S2 ]1 A* j0 v0 T5 y- k .name = "leds-gpio",
: }" x" ~4 t: w3 t2 c! c3 l .id = 1,% q( w% }9 A7 {5 o! s; G* F
.dev = {
' {1 H2 F1 z8 u .platform_data = &da850_evm_tl_leds_pdata,: j! C# _- k. N4 f) i
.release = led_dev_release,
# N( n% v! c8 i) M r- ~: w( D }
. h! g! ^9 x$ ]2 O};
, ^2 y% @1 [+ c! K" h" J p, ~$ v5 u- ~1 D5 ^+ X3 L& w# M
static int __init led_platform_init(void) y% _; j4 E0 h$ r! z5 ~, Z
{9 u3 X# v3 w$ |
int ret;( X! G5 d% b4 K) a9 s
#if 04 Z( r" l* l- o7 k3 }
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
6 {7 o8 E" F% N( f, J! d9 e* l3 G if (ret)
- a9 z# y% f% l# H: T pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
) Z9 b& G$ z# C "%d\n", ret);
! W/ s# e2 q( `, A( D7 P7 c# n2 o#endif
0 M: D3 C( H/ r8 l6 d" g: Q ret = platform_device_register(&da850_evm_tl_leds_device);
- Y0 i7 f: p( o; f0 j/ T, {$ |& x if (ret)
+ H6 m( U; \1 p& X* | pr_warning("Could not register som GPIO expander LEDS");
9 U/ j e+ R) ^# l" |' P else# ~! U l) m- k+ f; D# R+ j6 k/ F
printk(KERN_INFO "LED register sucessful!\n");" y! o; c- B( E
: b+ e0 q# D/ F0 r( N% N
return ret;% `6 B5 w8 O0 G1 d0 O, p! F4 H3 J
}
0 V( B% \1 P A4 \7 S V
, K8 w! z- s5 S, ~' Bstatic void __exit led_platform_exit(void)# u+ J% j3 k; t
{
* ^6 m) |: D/ U/ V. r' E3 \5 {& [2 E platform_device_unregister(&da850_evm_tl_leds_device);' l5 C7 ?; i" t% p( N* j. J$ ]4 R
8 N/ e/ j; o R# s. F printk(KERN_INFO "LED unregister!\n");
5 J' E$ b1 i; ]! D: E}) C& r o7 s- G# _) v" z
& C, [6 f: I6 f4 t* O* a
module_init(led_platform_init);: g3 }! A- i4 d5 W
module_exit(led_platform_exit);) h; X; Z( t! V7 O7 @
' p' \2 c3 y' ], r u; aMODULE_DESCRIPTION("Led platform driver");
9 X( U5 G5 c/ ]0 q" yMODULE_AUTHOR("Tronlong");. P* @2 n. i/ I3 O7 j
MODULE_LICENSE("GPL");& f9 s5 U7 [" A/ U
0 d8 m7 z6 U! H1 L
|
|