|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
$ ~$ E5 M; r) X- b" a) j#include <linux/init.h>
5 l, m' [: o' R' Z4 T* ]2 B; \#include <linux/module.h>- W1 J* S% N8 _5 F" \& Z
#include <linux/kernel.h>
; ^& z3 P) M0 p#include <linux/types.h>
7 r! f0 `8 \* Z, D# I; F#include <linux/gpio.h>
7 _' V0 |1 H3 c) o( T#include <linux/leds.h>7 W! \' X% Y3 H) n$ d
#include <linux/platform_device.h>
& Z2 u- F4 D) f6 `* a4 L! [1 L0 n! y' R% z
#include <asm/mach-types.h> e6 S7 z2 ~& ^1 W) v/ Q! \/ C
#include <asm/mach/arch.h>2 k0 k8 u x7 o$ o0 [
#include <mach/da8xx.h>
; |- Y0 O8 w, k#include <mach/mux.h>
# c9 |$ t% F: {% ?
h x$ {/ K i# Z#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)1 n5 s9 [) u/ R; D
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)* h7 Z6 |' X$ k+ q
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)7 `- h8 b- [* a7 `' ]
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
1 n% e C3 }" H) i% E8 n0 R" L+ m' D- Q9 T# u8 e! R
/* assign the tl som board LED-GPIOs*/
! P* K' V5 D+ U, Q+ w- o2 q1 g9 x8 ~static const short da850_evm_tl_user_led_pins[] = {
O C4 D1 ` M4 J2 h6 q /* These pins are definition at <mach/mux.h> file */7 K7 \% B* a# [: F" C0 `
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
' D" H2 f( Y; A% z) {+ T -1
% j* G' W; R8 P: Q; w9 U! p};
% V! ~4 s. |5 r. Y% l3 J8 C* N- P
static struct gpio_led da850_evm_tl_leds[] = {2 c5 l$ S/ o/ u5 w) b- s# f/ [
{0 M- H5 R, q* H. z' v9 Z2 a
.active_low = 0,* M' c" A' i: h5 K- u5 K9 u
.gpio = DA850_USER_LED0,
+ y4 v! ?# T3 x- F* h .name = "user_led0",4 _, u- L; l- v( U5 h6 ]( V! o' ]
.default_trigger = "default-on",
& f) t1 Z3 V$ W. j1 a },( [9 X, n# v& u/ C
{
m# @% R( o4 V; E2 T0 m3 Z0 D .active_low = 0,
3 {) h9 l% s. O/ E2 M7 ` .gpio = DA850_USER_LED1,
/ S. ^: _; {0 L2 x! _3 L$ o .name = "user_led1",
, u0 G! @( P& v# f& m$ k: k3 B .default_trigger = "default-on",
4 L; c" H ]3 u# h: P3 f },
7 y: }* Z7 }8 V! ~9 Y7 A {
2 ]% v" V# s1 Z6 v- K) Y .active_low = 0,
) ?( F8 A$ n5 |$ U7 m$ ] .gpio = DA850_USER_LED2,: X' H& g+ I' l) X8 \
.name = "user_led2",
. |- V+ b$ E! A .default_trigger = "default-on", s( }3 C, H1 b+ t0 l4 n. g
},: p' Q* B1 E* o1 t8 d0 X* c; D
{
$ v5 g+ t; n6 C: b% M& M7 ? .active_low = 0,
: G1 K. [; s; Q8 A .gpio = DA850_USER_LED3,: T- Y6 t. G# v
.name = "user_led3",( k# ]8 x0 X3 c& U
.default_trigger = "default-on",& R B% M4 N [" {/ g4 ~2 p. g
},
8 k7 J+ s' @1 X" _! W5 R- V9 d};
* s9 M c. ]4 [5 l# Y) w& y' Q
2 B# i0 U8 b" N" [0 Hstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
6 k) t7 n- W3 @0 @ [, l9 M1 F .leds = da850_evm_tl_leds,
& }2 B( N. t8 c% k1 M .num_leds = ARRAY_SIZE(da850_evm_tl_leds),8 s) A1 K4 U4 R$ d2 Z/ G
};; h+ j- i- p/ m) }. d
2 B* H' E2 r$ [; y7 lstatic void led_dev_release(struct device *dev)4 s* Z7 g# k0 _& k" {0 n
{
/ d- t1 \+ u; u};
' s6 Y7 y0 M7 X: M6 k5 e4 g! g- h& L- U1 G
static struct platform_device da850_evm_tl_leds_device = {) |+ o5 T& U8 q% F
.name = "leds-gpio",
3 ?7 _* s7 k$ b$ }1 j .id = 1,
& w" |3 Q6 C7 @7 v" e) e8 J .dev = {
/ h' u, v3 ~5 }& M% k/ k .platform_data = &da850_evm_tl_leds_pdata,
* u6 [2 X' ?& o4 H9 c .release = led_dev_release,
! F) T: @( Q' c& a8 H }
, g3 K$ d* o J& {};0 Y1 r+ l1 O8 H8 A/ X
# O- u& C2 _1 A I- _) hstatic int __init led_platform_init(void)
9 Z; }6 G( E2 b" |{: a9 h: h6 _" S6 m9 @7 M
int ret;
8 C* q' Q, L2 p2 q- D#if 0/ ]& p" @8 Y$ ?( n! W3 U3 i$ _
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);& z* \4 f. F. |" h w
if (ret)
* j; t. e i r8 ` Y u1 [4 U pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
1 `4 i/ Q7 P" Q "%d\n", ret);
( B7 ^+ u' v8 M#endif) ]: e' {! C @3 ?: ?# W
ret = platform_device_register(&da850_evm_tl_leds_device);' B1 n% G- Y2 H/ p$ l! ?9 V
if (ret)
* {& K# S& q T; V0 T$ g pr_warning("Could not register som GPIO expander LEDS");+ C- w! ]! c4 I8 V+ o# }: G
else# n5 o* l! W5 i% s. x3 H7 c6 T9 B9 t
printk(KERN_INFO "LED register sucessful!\n");
- z' y6 R# H3 U6 ^( C/ k. E- q; y; {" l ]# Z. L2 g# e ?
return ret;: f- _: T: r9 H9 r
}
: M7 s. q. T- O1 O: a) H3 ~# b% q2 h% q5 |
static void __exit led_platform_exit(void)0 X0 J2 A; y. B! Y' F
{
1 ]4 f! j; Y: m# `# f% N; i platform_device_unregister(&da850_evm_tl_leds_device);" ~: F3 r, A9 Q+ F; u5 L, I/ \
/ T9 n6 G' Q; v( D$ D: r' j9 F printk(KERN_INFO "LED unregister!\n");* {* [; w: v; M$ ^+ A( i. t7 E; N. n
}; h9 `- G7 }2 V
6 q7 L6 R9 `) U8 R& x/ m
module_init(led_platform_init);: D9 M' z0 J3 I/ A- w
module_exit(led_platform_exit);
, B4 D: o7 B- d, s; b3 k3 A: b D, w5 w* x) L
MODULE_DESCRIPTION("Led platform driver");
- c, I1 c# f( [8 J2 M6 Z# yMODULE_AUTHOR("Tronlong");
1 I/ z. c h9 a7 EMODULE_LICENSE("GPL");- P$ \' D( O+ g
* b% K% I! `- _3 \. c f9 l
|
|