|
|
求大神给下面的程序做注解,请稍详细些,谢谢。% \* Y. ^! n' e5 _; h! S {1 K! o
#include <linux/init.h>8 [& G1 J K5 y2 n# \
#include <linux/module.h>% x! {' }7 e! x2 [4 P6 i+ y& E
#include <linux/kernel.h>
$ ~, A$ e4 X6 m4 d$ ^#include <linux/types.h>
7 h# y4 H+ D% L: s, A. |* Q, Y0 N#include <linux/gpio.h>& W9 Y/ w# ]% |1 _; D6 N, l
#include <linux/leds.h>8 K0 a% O9 d: s
#include <linux/platform_device.h>. q" m% ~. i; s/ M. R v
5 r0 t; w# I. {) g5 o; J; n- D$ Y
#include <asm/mach-types.h>
$ H6 S% R; d* M2 D. B: c#include <asm/mach/arch.h>
1 S) F: m6 Q5 q4 e( f; Q) N#include <mach/da8xx.h>2 q' }1 _6 J' B2 Q
#include <mach/mux.h>) c2 U& c, u1 b( X: U9 l8 J
3 Y9 g5 m/ n/ R9 O4 }) s& e% f3 P5 |
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
9 i1 _- m& Z! l, y#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)- L8 ?+ L: @# S2 j0 }
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
1 e+ u0 Y+ ~! e9 j#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
- Y0 o* B2 n# w* Z0 G, h5 Q& |$ [+ Z! G& X
/* assign the tl som board LED-GPIOs*/
5 r) T+ h! {- i7 c" P" V- B9 {& `, s9 Gstatic const short da850_evm_tl_user_led_pins[] = {
W1 [! j! P& y- S6 \8 ? /* These pins are definition at <mach/mux.h> file */
1 Z4 w4 e* V. j- n$ k) Y DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,0 O2 M6 q7 M; n T% L
-1( A# U" J6 ]- ^3 b! H5 }/ h6 e n' D
};/ f$ p0 \7 Y' e4 \( k
" ~- Z. ]! a' Z$ E8 \% L5 R
static struct gpio_led da850_evm_tl_leds[] = {
7 t% a: D3 c1 [- p4 y' A B {1 k+ E( j; r; K7 C
.active_low = 0,
" X2 ?- p# S% L/ ^4 k& W .gpio = DA850_USER_LED0, m$ s% o# [% K- `/ {
.name = "user_led0",& Z! p; l, a) Z$ g" y2 ?& F. b
.default_trigger = "default-on",# _1 v; ^/ y/ r+ U$ H
},( F4 L6 n& P* A" V: v
{+ M3 h5 ]+ }. H1 V2 q; e4 G
.active_low = 0,
V( G1 B# E& h, G: A .gpio = DA850_USER_LED1, c/ Z- M4 }; E; u
.name = "user_led1", c3 Z2 T0 l9 R
.default_trigger = "default-on",
: L6 j* e) \! f$ {" ]+ t2 N },
; w% W. A5 X% V4 j0 t {
) b' q2 f- ?2 U3 C0 Z$ J .active_low = 0,3 Y, L. F1 v& n/ z
.gpio = DA850_USER_LED2,
. w! I1 w2 b' {/ f" k .name = "user_led2",
* {- d4 M6 c. o( D* C .default_trigger = "default-on",, c- U. K# y. g" ]: Q: G
},
) n: Q- x `% ]6 A4 ]$ } [4 G+ w {
9 ~$ X! U) p6 N* h- M) D/ Q .active_low = 0,
: S7 F9 A3 ?& v, E/ ] .gpio = DA850_USER_LED3,
) W6 a0 K0 a! y3 A8 N3 a .name = "user_led3",* k0 U7 |- J- a( Y B. a
.default_trigger = "default-on",& R9 D/ t) |' H) b
},
8 j- m7 K" r% p3 O};
" b/ N0 Y. q0 x' [' K4 u! v0 Q0 @5 y
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {3 `5 y& G! ^/ [& u
.leds = da850_evm_tl_leds,
; w. \9 T) U0 C/ t .num_leds = ARRAY_SIZE(da850_evm_tl_leds),8 |& `8 Z; _( S9 P2 R6 J
};# D3 _; x! ]0 m7 s
( u( k% A1 l; s V* n5 Istatic void led_dev_release(struct device *dev)) l0 _* o8 v; G
{
, R: u9 h. m c4 f# ?8 ^2 H/ k};5 g2 i! [5 c D" J
8 u8 u0 ]4 V7 p, R
static struct platform_device da850_evm_tl_leds_device = {( x/ }1 o. p; p! y
.name = "leds-gpio"," M% b5 S+ }7 G8 t
.id = 1,/ N5 K7 \( n5 U# v7 t
.dev = {
& d$ I, N1 h2 r: D .platform_data = &da850_evm_tl_leds_pdata,
$ b$ Y7 [/ @* u4 E( _ .release = led_dev_release,; W( O/ S6 m( V# L4 d" m( ]0 e, D6 Z
}- o# y6 s z0 R; A
};% D( B- r6 E& v/ c/ J, e
( E8 V$ G3 U; gstatic int __init led_platform_init(void)
" j: K- ?9 ]& @9 ^4 N; L9 `{
6 } k# K7 P* J9 ?: N int ret;' H( I+ }' ~3 D4 M
#if 02 T/ ~9 v. m1 I
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
9 B! ]. q" g* Q6 K if (ret)
' o0 n% h; L. V; o pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
8 q: p1 y$ R, @/ [ ~/ x "%d\n", ret);4 q: T0 a& O5 H B. ?+ e! n, C
#endif
/ A5 V/ J# {/ e2 V6 U/ n ret = platform_device_register(&da850_evm_tl_leds_device);
, O& H# p: u+ y3 b5 o* r0 m* y' x if (ret)
6 p8 ^; l6 T( v- x$ [ pr_warning("Could not register som GPIO expander LEDS");
8 m, p7 i2 Y. ~ else/ ~8 X( o9 ~+ F6 [5 S! O8 L& N8 n
printk(KERN_INFO "LED register sucessful!\n");5 l7 `) z: t% [. g5 i; m& r
! |8 f8 w3 A' m' [7 x; [( {! U
return ret;. ^8 S- z) d( ~ ^% n
}" @# `+ B2 o: }; p; w* E4 [
9 ~7 s# u; h! x1 `4 E/ Dstatic void __exit led_platform_exit(void)
1 p& ^6 G8 \3 h6 \( K{# f. a( P, O3 E3 E. y/ h
platform_device_unregister(&da850_evm_tl_leds_device);
; `& f- t( R, C" P* k& ?7 L- T4 b6 b, U/ _: n4 M( E
printk(KERN_INFO "LED unregister!\n");" u( z9 x/ O {0 C
}# {. F F2 |' k4 s; V8 j D
1 R& B% G. z* D# p4 Pmodule_init(led_platform_init);$ z7 \7 m5 i' m5 Q- S7 y
module_exit(led_platform_exit);0 L5 Y( M- O9 M1 E+ O9 m
$ J* z- t4 q" U! _% \2 k* z oMODULE_DESCRIPTION("Led platform driver");3 p6 l6 _! C0 G8 s; T- a; t+ a+ w
MODULE_AUTHOR("Tronlong");
2 u9 @ M5 A6 n m5 \MODULE_LICENSE("GPL");
2 m0 \) U, Z% n' z1 x" o. o1 J* C- e
|
|